简体   繁体   中英

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. in this case, imageLink is a list. doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM