擅长:python、mysql、java
<p>提供if条件,if锚定标记可用,然后获取<code>href</code>并附加它。你知道吗</p>
<pre><code>import requests
from bs4 import BeautifulSoup
soup=BeautifulSoup(requests.get("https://joboutlook.gov.au/A-Z").text,'html.parser')
urls = []
h4s = soup.find_all('h4')
for h4 in h4s:
a = h4.find('a')
if a:
href = a['href']
#print(href)
new_url ='https://joboutlook.gov.au/{}'.format(href)
#print(new_url)
urls.append(new_url)
print(urls)
</code></pre>