Running error episode :RequestsDependencyWarning:requests Library version mismatch
RequestsDependencyWarning: urllib3 (1.26.8) or chardet (3.0.4) doesn't match a supported version!
Solution :
1、 see requests Version of the library :pip list
2、 Uninstall old version :pip uninstall requests
3、 Download the latest version :pip instsall requests Search results · PyPI
4、 Rerun code : normal
import requests
url='https://search.worldbank.org/api/projects/all.csv'
res=requests.get(url)
file=open(' World Bank project list .csv','wb')# Create a csv file , Select binary mode ‘wb' Open file
file.write(res.content)# Write specific file contents
file.close()
Running results : Download successful
import requests
url='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwx2.sinaimg.cn%2Flarge%2F006gM0gnly1fubsej8xztj32bc1jk1g7.jpg&refer=http%3A%2F%2Fwx2.sinaimg.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1647513020&t=7cbced00c08883ca013c2b1dd09c246f'# Just load the picture address
res=requests.get(url)
file=open(' Song veyron .jpg','wb')# Create a jpg file , Select binary mode ‘wb' Open file
file.write(res.content)# Write specific file contents
file.close()
Running results :
import pandas as pd
url='http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/dzjy/index.phtml'
table=pd.read_html(url)[0]#pd.read_html(url) Get a list , So add [0] Extract the first element
print(table)
table.to_excel(' Block trading table .xlsx')# What's returned here is excel Table name , So the suffix should be added in quotation marks , Otherwise an error
Running results :