|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import re, urllib.request
#import sys
def open_url(url):
req = urllib.request.Request(url)
req.add_header('User-Agent','Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/9.5.0.17997')
response = urllib.request.urlopen(req)
html = response.read().decode('utf-8')
#non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
#html=html.translate(non_bmp_map)
#print(html)
def get_img():
p = r'<img class="BDE_Image" pic_type="0" width="560" height="312 src="[^"]+\.jpg"'
imglist = re.findall(p, '<img class="BDE_Image" pic_type="0" width="560" height="312" \src="https://imgsa.baidu.com/forum/w%3D580/sign=1cd510bbc43d70cf4cfaaa05c8ded1ba/0db79e315c6034a83d34fa03c61349540b2376f4.jpg">')
print(imglist)
if __name__ == '__main__':
url = 'http://tieba.baidu.com/p/5995461618'
open_url(url)
不知道为什么始终匹配不了 |
|