【发布时间】:2016-11-28 02:46:12
【问题描述】:
我想更改我的soup.find.all 的输出。在原始来源中,我们有这个:
<a href="/book/nfo/?id=4756888" class="ajax nfo"></a>
我的soup.find_all:
href = [b.get('href') for b in soup.find_all('a', href=re.compile(r'.*\?id\=\d{4,8}'))]
给我这个:
/book/nfo/?id=4756888
但我想要这个:
http://127.0.0.1/book/download/?id=4756888
【问题讨论】:
-
这是您想用下载替换 nfo 的单个 url /book/nfo/ 吗?
-
还有多少其他的url?
-
我还有很多其他的任何 url。
-
您必须列出所有 url 以获得解决方案,或者至少列出它们都遵循的通用模式。但是通过阅读以下答案,您可能已经了解了如何解决。
-
Mohammad Yusuf Ghazi 的解决方案为我工作。
标签: python regex beautifulsoup