Rumah > Soal Jawab > teks badan
Perihalan masalah: ValueError: aksara format 'j' (0x6a) tidak disokong pada indeks 21
Iaitu, baris ke-6 dari bawah .jpg Apa yang salah dengan j? ? ?
import urllib.request
daripada bs4 import BeautifulSoup
def get_content(url):
html = urllib.request.urlopen(url)
content = html.read().decode('utf-8')
html.close()
return content
def get_image(info):
soup = BeautifulSoup(info,"lxml")
all_image = soup.find_all('img',class_="BDE_Image") #一个一个保存
x=1
for image in all_image:
print(image)
urllib.request.urlretrieve(image['src'],"C:\Users\jack Lee\s%.jpg" %(x))
x+=1
url = "https://tieba.baidu.com/p/2218566379"
info = get_content(url)
print (info)
get_image(info)