import requests
from bs4 import BeautifulSoup
'''
It's a web crawler working in ebay, collecting every single item data
'''
def ebay_spider(max_pages):
page = 1
while page <= max_pages:
url = 'http://www.ebay.co.uk/sch/Apple-Laptops/111422/i.html?_pgn=' \
+ str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findAll('a', {'class': 'vip'}):
href = 'http://www.ebay.co.uk' + link.get('href')
title = link.string
get_single_item_data(href)
page += 1
def get_single_item_data(item_url):
source_code = requests.get(item_url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for item_name in soup.findAll('h1', {'id': "itemTitle"}):
print(item_name.string)
ebay_spider(3)
Blockquote And the error say that : http://imgur.com/403a6N8
I tried to fix it but it seems not to work, so any tips/answers how to fix it?Python BS4 ModulEDIT: Sorry everyone for faulty title and tag, everything was fixed.
haben Sie versucht, was es Ihnen sagt? 'supp = BeautifulSoup (reiner_text," html.parser ", markup_type = markup_type)'. Und bitte posten Textversion des Fehlers, nicht ein unlesbares Bild. –
Das hat nichts mit dem Modul 'requests' zu tun. – DeepSpace
@ Jean-François Fabre sorry Kumpel für schlechtes Bild, aber Sie haben Fehler richtig eingelesen. Aber das Problem ist, dass ich diese Zeile in meinen Code eingefügt habe und ein Fehler erscheint, der besagt: SyntaxError: ungültiges Zeichen in Bezeichner. Aus irgendeinem seltsamen Grund kann ich nicht herausfinden, was damit nicht stimmt. Und hier ist der vorherige Fehler, welcher Beitrag war über: http://pastebin.com/HNL1ENG0 – Auginis