Skip to main content

Simple python library that uses puppeteer to pull HTML from a loaded SPA (REQUIRES NODE, NPM, AND PUPPETEER)

Project description

# JavaSoup - Modern Web Scraping

This library returns the HTML of a Single Page Application (SPA) after the page has loaded. This HTML can then be passed to BeautifulSoup for parsing.

#### !! WARNING: This library requires node, npm, and puppeteer to work !! ##### !! If the method runs and nothing is returned, this is MOST LIKELY the issue !!

##### Install JavaScript Components (on Kali):

sudo apt-get install -y nodejs npm

npm i puppeteer

### Library Overview

The traditional method of web scraping in Python w/ requests and BeautifulSoup isn’t effective for more modern pages and SPAs. This library dynamically generates a JavaScript file that uses puppeteer to fully load the page and return the HTML that is dynamicaly generated in the Document Object Model (DOM).

The primary method, get_soup, accepts a full URL as a string and returns the page’s content as a string.

Typical Workflow (requests/BeautifulSoup):

res = requests.get(‘http://example.com’)

soup = BeautifulSoup(res.text, ‘html.parser’)

New Workflow w/ javasoup:

import javasoup

soup = BeautifulSoup(javasoup.get_soup(‘http://example.com’), ‘html.parser’)

### Execution Process

  1. Creates the necessary JavaScript file in the current working directory (MUST HAVE WRITE PRIVILEGES)

  2. Runs that JavaScript file using the URL provided and stores the value returned

  3. Deletes the temporary JavaScript file

  4. Returns the HTML content

### Install

#### After JavaScript components have been installed, javasoup can be downloaded through pip

pip install javasoup

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

javasoup-0.8.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file javasoup-0.8.tar.gz.

File metadata

  • Download URL: javasoup-0.8.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for javasoup-0.8.tar.gz
Algorithm Hash digest
SHA256 b44b92e0fcfe7b150dd09e2b16f72a3392e574db3ef3e56168c89b64cccc68be
MD5 e0c61442a87fb4e630261ceb00c5dd89
BLAKE2b-256 1418d47fb4266262f513545fed8f0dbb0346813639f4a06edea10d6559ad9de0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page