나는 최근에 thenewboston을 보았습니다 python을 사용하여 웹 크롤러를 작성하는 것에 관한 비디오. 웬일인지, 나는 SSLError를 얻고있다. 코드 6 행으로 해결했지만 행운은 없었습니다. 왜 그것이 오류를 던지고 있는지 어떤 생각? 코드는 축 어적입니다 thenewborston입니다.Python 웹 크롤러 fromewboston
import requests
from bs4 import BeautifulSoup
def creepy_crawly(max_pages):
page = 1
#requests.get('https://www.thenewboston.com/', verify = True)
while page <= max_pages:
url = "https://www.thenewboston.com/trade/search.php?pages=" + str(page)
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for link in soup.findAll('a', {'class' : 'item-name'}):
href = "https://www.thenewboston.com" + link.get('href')
print(href)
page += 1
creepy_crawly(1)
SSL 오류가 때문입니다 웹 인증서. 크롤링하려는 URL이'https '이기 때문에 아마 일어날 것입니다. http 만 사용하여 다른 사이트를 사용해보십시오. – Craicerjack
가능한 복제본 http://stackoverflow.com/q/10667960/783219 – Prusse
감사합니다. Craicerjack! 나는 "http"가없는 웹 사이트에서 그것을 시도했고 효과가있었습니다! 그러나 "https"가있는 도메인에서 웹 크롤러를 실행하려면 어떻게해야합니까? – Steven