A Smart, Automatic, Fast and Lightweight Web Scraper for Python
Python aiartificial-intelligenceautomationcrawlermachine-learningpythonscrapescraperscrapingweb-scrapingwebautomationwebscraping
Update README.md
Alireza Mika2342776d9e13
diff --git a/README.md b/README.mdindex 9024798..de64e18 100644--- a/README.md+++ b/README.md@@ -123,63 +123,5 @@ And to load:scraper.load('yahoo-finance')```-### Grouping results and removing unwanted ones--Here we want to scrape product name, price and rating from ebay product pages:--```python-url = 'https://www.ebay.com/itm/Sony-PlayStation-4-PS4-Pro-1TB-4K-Console-Black/203084236670'--wanted_list = ['Sony PlayStation 4 PS4 Pro 1TB 4K Console - Black', 'US $349.99', '4.8']--scraper.build(url, wanted_list)-```-The items which we wanted have been on multiple sections of the page and the scraper tries to catch them all. So it may retrieve some extra information compared to what we have in mind.-Let's run it on a different page:-```python-scraper.get_result_exact('https://www.ebay.com/itm/Acer-Predator-Helios-300-15-6-144Hz-FHD-Laptop-i7-9750H-16GB-512GB-GTX-1660-Ti/114183725523')-```-The result:-```python-[- "Acer Predator Helios 300 15.6'' 144Hz FHD Laptop i7-9750H 16GB 512GB GTX 1660 Ti",- 'ACER Predator Helios 300 i7-9750H 15.6" 144Hz FHD GTX 1660Ti 16GB 512GB SSD⚡RGB',- 'US $1,229.49',- '5.0'-]-```-As we can see we have one extra item here. We can run the `get_result_exact` or `get_result_similar` method with `grouped=True` parameter. It will group all results per its scraping rule:--```python-scraper.get_result_exact('https://www.ebay.com/itm/Acer-Predator-Helios-300-15-6-144Hz-FHD-Laptop-i7-9750H-16GB-512GB-GTX-1660-Ti/114183725523', grouped=True)-```--Output:-```python-{- 'rule_sks3': ["Acer Predator Helios 300 15.6'' 144Hz FHD Laptop i7-9750H 16GB 512GB GTX 1660 Ti"],- 'rule_d4n5': ['ACER Predator Helios 300 i7-9750H 15.6" 144Hz FHD GTX 1660Ti 16GB 512GB SSD⚡RGB'],- 'rule_fmrm': ['ACER Predator Helios 300 i7-9750H 15.6" 144Hz FHD GTX 1660Ti 16GB 512GB SSD⚡RGB'],- 'rule_2ydq': ['US $1,229.49'],- 'rule_buhw': ['5.0'],- 'rule_vpfp': ['5.0']-}-```--Now we can use `keep_rules` or `remove_rules` methods to prune unwanted rules:--```python-scraper.keep_rules(['rule_sks3', 'rule_2ydq', 'rule_buhw'])--scraper.get_result_exact('https://www.ebay.com/itm/Acer-Predator-Helios-300-15-6-144Hz-FHD-Laptop-i7-9750H-16GB-512GB-GTX-1660-Ti/114183725523')-```--And now the result only contains the ones which we want:-```python-[- "Acer Predator Helios 300 15.6'' 144Hz FHD Laptop i7-9750H 16GB 512GB GTX 1660 Ti",- 'US $1,229.49',- '5.0'-]- ```+Check out [here](https://gist.github.com/alirezamika/72083221891eecd991bbc0a2a2467673) for more advanced usages.#### Happy Coding ♥️