新手 - Python 爬蟲 問題 求助
問題描述
問題描述: ValueError:unsupported format character ’j’ (0x6a) at index 21即倒數(shù)第6行 .jpg j出什么問題了???import urllib.requestfrom bs4 import BeautifulSoupdef 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') #一個(gè)一個(gè)保存x=1for image in all_image: print(image) urllib.request.urlretrieve(image[’src’],'C:Usersjack Lees%.jpg' %(x)) x+=1
url = 'https://tieba.baidu.com/p/2218566379'info = get_content(url)print (info)get_image(info)
問題解答
回答1:是%s ,而不是 s%
相關(guān)文章:
1. php多任務(wù)倒計(jì)時(shí)求助2. 為何 localStorage、sessionStorage 屬于html5的范疇,但是為何 IE8卻支持?3. win10 python3.5 matplotlib使用報(bào)錯(cuò)4. MySQL的聯(lián)合查詢[union]有什么實(shí)際的用處5. mysql 遠(yuǎn)程連接出錯(cuò)10060,我已經(jīng)設(shè)置了任意主機(jī)了。。。6. html5 - css3scale和rotate同時(shí)使用轉(zhuǎn)換成matrix寫法該如何轉(zhuǎn)換?7. 默認(rèn)輸出類型為json,如何輸出html8. PHP訂單派單系統(tǒng)9. python的正則怎么同時(shí)匹配兩個(gè)不同結(jié)果?10. 數(shù)組排序,并把排序后的值存入到新數(shù)組中
