我试图运行这段代码,但它给出了值错误。
ValueError:未知的 url 类型:'/images/christmas-getaway-2017.jpg'
请通过此代码:
import requests
import urllib.request
from bs4 import BeautifulSoup
from html.parser import HTMLParser
url = 'https://yts.movie/search/all/all/all/latest/'
response = requests.get(url)
response
soup = BeautifulSoup(response.text, 'html.parser')
print(soup.prettify())
frame = soup.findAll('div',{'class':'browse-movie-wrap col-xs-10 col-sm-5'})
for frame in frame:
figure = frame.find('figure')
photo_url = figure.img['src']
print(photo_url)
name = photo_url.split('/')
name = name[-1]
urllib.request.urlretrieve(photo_url, name)