We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent3dc9856 commit573368bCopy full SHA for 573368b
scraper.py
@@ -0,0 +1,30 @@
1
+importrequests
2
+frombs4importBeautifulSoup
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
+forbookinall_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()