![](/img/trans.png)
[英]retrieve specific links from web page using python and BeautifulSoup
[英]What's the easiest way to extract the links on a web page using python without BeautifulSoup?
我正在使用cygwin,但未安裝BeautifulSoup。
如果您不太在意性能,則可以使用正則表達式:
import re
linkre = re.compile(r"""href=["']([^"']+)["']""")
links = linkre.findall(your_html)
如果只想使用http://鏈接中的鏈接,則將表達式更改為:
linkre = re.compile(r"""href=["']http:([^"']+)["']""")
或者,如果有可能您的鏈接周圍沒有html,則可以將“”作為可選。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.