鱼C论坛

 找回密码
 立即注册
查看: 3242|回复: 1

python正则表达式不能匹配的问题!

[复制链接]
发表于 2014-4-30 09:51:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 K。 于 2014-4-30 10:14 编辑

#python3.3
import re
import urllib.request

response = urllib.request.urlopen("http://apk.hiapk.com/apps#1_1_0_0_0_0_0")
html = response.read()
myhtml = html.decode('utf8')
response.close()
print(myhtml)
#myhtml里面内容很正常,下方这个链接也能找到。就是匹配不出来。
#http://down.apk.hiapk.com/Download?aid=2498588  \d{7}

compare = re.compile(r'http://down\.apk\.hiapk\.com/Download\?aid=2498588')
URL = compare.match(myhtml)#匹配失败
if URL:
    print(URL.group())
else:
    print('匹配失败')

一直匹配失败,我就郁闷了。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2014-4-30 21:26:15 | 显示全部楼层
import re
import urllib.request

response = urllib.request.urlopen("http://apk.hiapk.com/apps#1_1_0_0_0_0_0")
html = response.read()
myhtml = html.decode('utf8')
response.close()
#print(myhtml)
#myhtml里面内容很正常,下方这个链接也能找到。就是匹配不出来。
#http://down.apk.hiapk.com/Download?aid=2498588  \d{7}

re_bds=r'href="(.*?)&module=64&info=&rel=nofollow" rel="nofollow">'
url=re.findall(re_bds,myhtml)
print(url)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-16 02:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表