Traceback (most recent call last):
File "D:/PyDate/Climb_CTOLib.com/Android_Climb.py", line 28,in<module>
link = links.find_all(re.compile('^a'))['href']
TypeError:list indices must be integers or slices,notstr
原因:
就是list的索引必须是整数或者切片,而不是str
解决:
重新对整个选择器进行编辑,获取新的列表数据
更改后:
request_get_html = urllib.request.Request(url=link_android, headers=headers)
comtent = urllib.request.urlopen(request_get_html).read().decode()
soup = BeautifulSoup(comtent,'lxml')
link_more = soup.find_all(class_="chapter")for links in link_more:
link = links.find_all('a')[0]['href']
list_s.append(link)