0
我使用的代碼,如下面下一頁解析頁:如何用美麗的湯來解析下一頁?
def parseNextThemeUrl(url):
ret = []
ret1 = []
html = urllib.request.urlopen(url)
html = BeautifulSoup(html, PARSER)
html = html.find('a', class_='pager_next')
if html:
html = urljoin(url, html.get('href'))
ret1 = parseNextThemeUrl(html)
for r in ret1:
ret.append(r)
else:
ret.append(url)
return ret
但我得到了如下錯誤,我怎麼能分析下一個鏈接,如果有一個環節。
Traceback (most recent call last):
html = urllib.request.urlopen(url)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 162, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 456, in open
req.timeout = timeout
AttributeError: 'list' object has no attribute 'timeout'
你可以給我們網絡鏈接?如果不知道網頁,我們無法確定。 – Seekheart
'http://003.b2btoys.net/en/ProductList.aspx?Class1 = 12'' http://003.b2btoys.net/en/ProductList.aspx?PageIndex = 2&Class1 = 13&Class2 = 0&type =&keyWord =' – mikezang