我一直在試圖導入一個名爲requests的模塊,它位於site-packages文件夾中。它是通過點安裝,但每次我嘗試導入它時,我得到的錯誤「ImportError:沒有名爲'request'的模塊」無法在站點包目錄中導入模塊?
我正在使用「導入請求」導入。
import requests
from bs4 import BeautifulSoup
def spider(max_pages):
page = 1
while page <= max_pages:
url = "http://www.ebay.ie/sch/Laptops-Netbooks/175672/i.html?_catref=1&_pgn=" + str(page) + "&_skc=50&rt=nc"
source_code = requests.get(url)
plain = source_code.text
soup = BeautifulSoup(text)
for link in soup.findAll('a', {'class': 'img'}):
href = "http://www.ebay.ie" + link.get('href')
title = link.string
print(href)
print(title)
page += 1
spider(1)
我想知道如果它與我的環境變量或如果我已經安裝了他們錯了。
您應該使用'import requests'。我猜這是一個錯字。 – dunder
仍未導入。 –
我會檢查@Orions的答案。 – vyscond