Heim  >  Fragen und Antworten  >  Hauptteil

Neuling – Hilfe bei Problemen mit dem Python-Crawler

Problembeschreibung: ValueError: nicht unterstütztes Formatzeichen „j“ (0x6a) an Index 21
Das heißt, die 6. Zeile von unten.jpg Was stimmt mit j nicht? ? ?
urllib.request importieren
aus bs4 importieren 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)

phpcn_u1582phpcn_u15822636 Tage vor841

Antworte allen(1)Ich werde antworten

  • 迷茫

    迷茫2017-07-05 10:37:09

    %s ,而不是 s%

    Antwort
    0
  • StornierenAntwort