擅长:python、mysql、java
<p>请为您的问题使用适当的标签,并分享您的代码,这样我们就知道您做了多少,而不是提供完整的答案。谢谢</p>
<p>试试这个:</p>
<pre><code>from bs4 import BeautifulSoup
import requests, re
''' Don't forget to install/setup package = 'lxml' '''
url = "http://www.github.com"
response = requests.get(url)
data = response.text
soup = BeautifulSoup(data,'lxml')
tags = soup.find_all('a')
''' This will print every available link'''
for tag in tags:
print(tag.get('href'))
''' this will print links with only prefix as given'''
for link in soup.find_all('a',attrs={'href': re.compile("^https://github")}):
print(link.get('href')
</code></pre>