import urllib.request
import re
def url_open(url):
    req=urllib.request.Request(url)
    req.add_header('User-Agent','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36')
    page=urllib.request.urlopen(req)  
    html=page.read().decode('utf-8')
    return html

def get_img(url):

    p=r'(?:(?:\d\d\d|\d\d|\d)\.){3}(?:\d\d\d|\d\d|\d)'
    iplist=re.findall(p,html)

    for each in iplist:
        print(each)

if __name__=='__main__':
     url='http://www.xicidaili.com/'
     html=url_open(url)
     iplist=get_img(html)
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐