Manny
Manny

Reputation: 1

How Can I Add PhantomJS to My Chrome Extension?

I need to scrape (public) HTML Data after the JavaScript on the page has loaded. After doing some research, I found that PhantomJS can be useful in accomplishing this task. However, while I can add PhantomJS to my local computer, I don't know how to add it to my chrome extension. Does anybody know how I can accomplish this?

Upvotes: 0

Views: 952

Answers (1)

Eejdoowad
Eejdoowad

Reputation: 1381

You cannot. PhantomJS is a web browser, not a Javascript library.

Alternative 1. Scrape from the Chrome Extension

You can use the chrome extension APIs to do the following:

  1. Create a tab containing the page you want to scrape
  2. Load a content script into the tab that:
    1. Waits for the page to finish loading
    2. Scrapes the data you want
    3. Messages the scraped data to wherever you need it
  3. Close the tab

Alternative 2. Scrape with a Headless Browser Running on Your Own Server

Use Google's own headless Chrome library puppeteer to scrape the data you want. An easy way to get started for free is with a Google App Engine Standard Tier NodeJS instance.

Upvotes: 1

Related Questions