python 网页编码 乱码

import requests,sys
from bs4 import BeautifulSoup
def gethml(url):
    rr=requests.get(url)
    s=rr.content
    s.decode("ISO-8859-1")
    return s
html=gethml(url)
soup =BeautifulSoup(html, "lxml")
for itema in soup.select(".cname"):
import random,string
passwd="https://jobs.51job.com/all/"
num=string.digits
for i in range(10):
   passwd+=random.choice(num)
passwd+=".html"
print (passwd)

 

posted @ 2021-10-24 19:20  myrj  阅读(52)  评论(0)    收藏  举报