1
我的工作是由有2场,URL和标题的HTML页面检索列表中的代码...Python中添加一个字符串匹配列表与多个项目
的URL反正有/URL....
启动,并我需要附加“http://website.com”给每个从re.findall
返回的变化。
到目前为止的代码是这样的:
bsoup=bs(html)
tag=soup.find('div',{'class':'item'})
reg=re.compile('<a href="(.+?)" rel=".+?" title="(.+?)"')
links=re.findall(reg,str(tag))
*(append "http://website.com" to the href"(.+?)" field)*
return links
http://stackoverflow.com/a/1732454/1459669请使用美丽的汤来找到链接! –
@CrazyPython除非你想召唤克苏鲁。 – timgeb
@timgeb你永远不知道,他可能想要召唤他。然后我们需要将它迁移到StackExchange Skeptics或Worldbuilding ... –