[英]How to fetch data for my website from 3rd party website in Django
我建議改用 API 操作,因為它們是為與應用程序交互而設計的。 如果您嘗試以編程方式訪問搜索結果,Google 可能會產生懷疑,並要求您填寫驗證碼以證明您是人類。
除此之外,這是你將如何做到的:
requests
獲取網站的 HTML 內容例如:
from bs4 import BeautifulSoup
import requests
url = 'https://www.accuweather.com/en/no/oslo/254946/current-weather/254946'
r = requests.get(url) # get the page content using requests
soup = BeautifulSoup(r, 'html.parser') # parse the page HTML
current_temp = soup.select('.display-temp').get_text() # locate the element of interest, and get the element's text content
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.