[英]Attribute Error :: 'list' object has no attribute 'split'
I am trying to split the links of the images what is wrong in my code我正在尝试拆分图像的链接我的代码有什么问题
mainURL = "https://w.cima4u.ws/category/%d8%a7%d9%81%d9%84%d8%a7%d9%85-
%d9%83%d8%b1%d8%aa%d9%88%d9%86-movies-anime/"
headers = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like
Gecko) Chrome/96.0.4664.93 Safari/537.36"}
s = requests.Session()
r = s.get(mainURL)
soup = BeautifulSoup(r.content, "html.parser")
for movie in soup.findAll('li', {'class':'MovieBlock'}):
movieLink = movie.find('a')
imageLink = movie.find('div', {'class':'Half1'})
imageLink = (['style'])
imageLink = imageLink.split("url(")[1][:-2]
print(imageLink)
since you didn't added the full stack trace, i suppose the error originating in this line由于您没有添加完整的堆栈跟踪,我想错误源于这一行
imageLink = imageLink.split("url(")[1][:-2]
split cannot be executed on a list, but on a string. split 不能在列表上执行,而是在字符串上执行。 in this case,
imageLink
is a list.在这种情况下,
imageLink
是一个列表。 doc文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.