1
위의 링크에서 애플 윌리엄스 버그 하이퍼 링크 아래에있는 URL을 "https://www.swarmapp.com/c/dZxqzKerUMc"으로하는 방법을 가정 해 보겠습니다.Swarm3 웹 페이지에서 Foursquare URL 위치를 추출하려면 어떻게해야합니까?
나는 HTML 태그에 따라 필터링하려고했지만 많은 태그와 많은 foursquare.com 링크가 있습니다. 아래 때문에 모든 주어진 떼 URL의 고유 특정 URL을 얻을 수있는 가장 좋은 방법은 무엇인가,
<h1><strong>Kristin Brooks</strong> at <a
href="https://foursquare.com/v/apple-williamsburg/57915fa838fab553338ff7cb"
target="_blank">Apple Williamsburg</a></h1>
항상 코드의 URL 포 스퀘어 같은 위의 주어진 링크의 소스 코드의 일부이다.
나는이 시도 : 이import bs4
import requests
def get_4square_url(link):
response = requests.get(link)
soup = bs4.BeautifulSoup(response.text, "html.parser")
link = [a.attrs.get('href') for a in
soup.select('a[href=https://foursquare.com/v/*]')]
return link
print (get_4square_url('https://www.swarmapp.com/c/dZxqzKerUMc'))