Skip to main content

PCPartScraper

Author: Jeet Chugh

PCPartScraper is a simple, yet powerful pcpartpicker.com WebScraper that extracts Data from Part URL's.

Features:

  • Search for Parts from String Queries
  • View: name, type, sale_link, price, specifications, url, rating, reviews, queries
  • Install easily with pip
  • Lightweight, only uses Requests and BS4 BeautifulSoup

Quick and Easy Installation via PIP: pip install pcpartscraper

Import Statement: from pcpartscraper.scraper import Part,Query

Dependencies: bs4, cloudscraper

Code License: MIT

Documentation

Documentation is split into 2 sections. First is the 'Part' Class and second is the 'Query' Function.

'Part' Class:

Part takes in an input of a URL as a string, and has many methods that return specific chunks of data.

Example1 Part: '/product/jxJwrH/intel-cpu-bx80623i52400' is a WD Blue 1tb Hard drive

Example2 Part: '/product/jxJwrH/intel-cpu-bx80623i52400' is an Intel i5-2400 Proccesor

Import:

from pcpartscraper.scraper import Part

Instantiation:

part1 = Part('/product/jxJwrH/intel-cpu-bx80623i52400') # Takes in url string (no .com)

part2 = Part('/product/jxJwrH/intel-cpu-bx80623i52400') # Organize different parts in variables

'Part' Methods:

methods return None if encountering Errors

Part('url').name()

returns a string containing the name of the part.

(Western Digital 1 TB 3.5" Hard Drive, etc.)


Part('url').type()

returns a string containing the type of the part

(Storage, Memory, Video Card, CPU Cooler, etc.)


Part('url').amazon_link()

returns a string containing the URL to the amazon listing for the product, if available. returns None if unavailable.

('https://www.amazon.com/dp/B004EBUXIA?tag=pcpapi-20&linkCode=ogi&th=1&psc=1', etc)


Part('url').price()

returns a float value for the cheapest price available for the part.

(34.99, 93.01, 45.62, etc.)


Part('url').advanced_specs()

returns a dictionary containing key/value pairs that correspond to the "specifications" sidebar for the part

Example Dictionary:{'model':'Intel','Core Clock':'3.2Ghz','TDP':'95W','Socket':'LGA1155'}


Part('url').url()

returns a string containing the runnable link for the part.

(https://pcpartpicker.com/product/jxJwrH/intel-cpu-bx80623i52400, etc.)


Part('url').rating()

returns a float value containing the review rating score, out of 5, for the part.

(3.6, 4.7, 1.3, 5.0, etc.)


Part('url').reviews(results=1)

inputs = results. The number of reviews that you want to pull from the part page.

returns a list containing x amount of text-reviews for a part. Reviews are from the part page, and are unfiltered.

(['really fast and good looking!','runs a little hot, but runs games extremely well!','Not good, waste of money.'], etc.)


'Query' Function:

Query takes in (url as a string), (results as an int), (exclude_laptops as a bool), (pages as an int)

Import:

from pcpartscraper.scraper import Query

Instantiation:

result_list = Query(search_term='ryzen 5',results=1,exclude_laptops=True,pages=1)

'Query' Inputs:

returns a list containing 'Part' classes pertaining to results.

Query(search_term='')

search_term is the keywords for finding a part through query. Main "searching" input.

(Western Digital , G-SKill, Cooler Master Hyper, 8gb RAM, etc.)


Query(results=3)

results is the number of results that you want to be returned in the returning list

The default value for result is 3, and the max is 20. > Results = More time usage

(6, 11, 3, 5, 1, 20, 13, etc.)


Query(exclude_laptops='search for a part')

Because of the laptop update to pcpartpicker.com, searching for parts often only result in laptops

exclude_laptops will ensure that no elements in the returning list contain instances of laptops.

The default value for exclude_laptops is True

(True, False)


Query(pages=1)

Searching for popular parts ends up with many pages to navigate through

pages is the number of pages that you want to span across. If 5, it will navigate the (results) # of top results for (pages)

The default value for pages is 1, as it greatly increases script execution timing.

(True, False)


Query('ryzen 5',3,True,1)

This example would return a list containing 3 'Part' objects for the top 3 searches on the first page pertaining to 'ryzen',excluding laptops.

A return would look like this

print(Query('ryzen',3,True,1)) --> [Part Object at x,Part Object at y,Part Object at z]


Thank you for reading the documentation. If you need an example using all these methods, go to [link]

If you have issues, report them to the github project link.

CHANGELOG

0.0.1 (7/8/20):

  • Release on PyPi
  • Fixed Text errors
  • Added example.py file

1.0.0 (7/8/20):

  • Updated Release
  • Attempted to fix Import Statement
  • Created Module Folder Architecture
  • Fixed ReadME.md

1.0.1 (7/8/20):

  • Fixed REAME
  • Updated Example.py

1.0.2 (7/8/20):

  • Accidentally Corrupted Changes
  • Final ReadME
  • GitHub commits

1.0.3 (7/8/20):

  • setup.py Final Changes
  • ReadMe.md Final
  • Added PyPi tags

1.0.4 (7/8/20):

  • Stable Release

1.0.5 (7/9/20):

  • Fixed Links in README.md

1.0.6 (7/9/20):

  • Improved Part.reviews() code execution speed/readability
  • Beta Testing for Multiple Paged Query's
  • Query Now Takes in a 'pages' Input

1.0.7 (7/10/20):

  • Fixed An Error when Getting Part().price()

1.0.8 (7/10/20):

  • Fixed an error that I caused in 1.0.7
  • Stable Release

1.0.9 (10/5/20):

  • Implemented cloudscraper
  • THIS DOES NOT FIX THE CAPTCHA ISSUE

1.1.0 (10/5/20):

  • Updated README
  • Updated Requirements

Metadata

Release files for pcpartscraper 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pcpartscraper 1.1.0
File Size Uploaded Provenance Actions
pcpartscraper-1.1.0.tar.gz 8.3 kB Without provenance Details for pcpartscraper-1.1.0.tar.gz

Release files / pcpartscraper-1.1.0.tar.gz

Download URL pcpartscraper-1.1.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4ea7e6f7d00c1d6623c0c703440c445af28e087a02741844127e510216813afd
BLAKE2b-256 checksum
How to use checksums
5fb392970ab63032a7604c2a0b0ede4e954a6b6fd3c0086144b0bc64d7fa6bab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Security for pcpartscraper 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page