Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bs4, requests
- def ebay(search):
- res = requests.get('http://www.ebay.in/sch/i.html?_from=R40&_trksid=p2050601.m570.l1313.TR11.TRC1.A0.H0.Xraspberry+pi.TRS0&_nkw=%s&_sacat=0' % search)
- home_page_object = bs4.BeautifulSoup(res.text, "html.parser")
- elements = home_page_object.find_all("li", {"class" : "sresult lvresult clearfix li"})
- name = []
- price = []
- link = []
- for e in elements:
- item_name = e.select("a")[1]
- item_price = e.select("span")[0]
- item_link = e.select("a")[1]
- if item_name.contents[0] != "\n" and len(item_price.contents) == 3:
- name.append(item_name.contents[0])
- price.append(item_price.contents[2])
- link.append(item_link["href"])
- for n, p, l in zip(name, price, link):
- print(n, ":", p, ":", l)
- ebay("raspberry pi")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement