Skip to content

Commit 573368b

Browse files
authored
Add files via upload
1 parent 3dc9856 commit 573368b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scraper.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
proxy = {'http': 'http://SPusername:SPpassword@gate.smartproxy.com:7000'}
5+
url = 'http://books.toscrape.com/catalogue/page-1.html'
6+
7+
r = requests.get(url, proxies=proxy)
8+
html = BeautifulSoup(r.content, 'html.parser')
9+
10+
all_books = html.find_all('article', class_='product_pod')
11+
12+
for book in all_books:
13+
title = book.h3.a['title']
14+
price = book.find('p', class_='price_color').text
15+
availability = book.find('p', class_ ='instock availability').text.strip()
16+
link_to_book = book.h3.a['href']
17+
18+
link = "http://books.toscrape.com/catalogue/{0}".format(link_to_book)
19+
20+
r2 = requests.get(link)
21+
html2 = BeautifulSoup(r2.content, 'html.parser')
22+
23+
description = html2.find('p', class_='').text
24+
25+
print(title)
26+
print(price)
27+
print(availability)
28+
print("{0}...".format(description[:150]))
29+
print(link)
30+
print()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy