0
这里是我的代码现在:的Python Crawling-类型错误:“诠释”对象不是可迭代
front_deeplink = ("http://www.jsox.de")
Spider = 20
Region = 7236
def trade_spider(max_pages):
for reg in Region:
page = 0
while page <= max_pages:
page += 1
r = requests.get("http://www.jsox.de/affiliatesearch.aspx?®ionid=" + str(reg) + "&pid=" + str(page))
soup = BeautifulSoup(r.content)
g_data = soup.find_all("div", {"class": "gridHeadOuter productInfoOuter"})
for item in g_data:
Header = item.find_all("div", {"class": "offerInto"})
Header_final = (Header[0].contents[0].text.strip())
price = item.find_all("strong", {"class": "priceBig priceBlock"})
Price_final = (price[0].text.strip())
Deeplink = item.find_all("a")
for t in set(t.get("href") for t in Deeplink):
Deeplink_final = (str(front_deeplink) + t)
print("Header: " + Header_final + " | " + "Price: " + Price_final[:-1] + " | " + "Deeplink: " + Deeplink_final)
trade_spider(int(Spider))
不过,我不断收到错误消息:
for reg in Region:
TypeError: 'int' object is not iterable
当我尝试
和运行这个。
我在做什么错?
任何人都可以帮助我吗?任何反馈意见。
你已经定义了'Region = 7236',它是一个'int',所以就像错误所说的那样,你不能迭代它。 – agold
你想做什么?你应该怎么处理数字7236? –
7236简化为一个区域的数字,例如罗马 –