ウェブサイトをクロールしたいです。Python AttributeError: 'str'オブジェクトに 'get'属性がありません
ただし、エラーが発生しました。
C:\Users\xxx\AppData\Local\Programs\Python\Python36\python.exe C:/Users/xxx/Desktop/scrap.py
Traceback (most recent call last):
File "C:/Users/xxx/Desktop/scrap.py", line 10, in <module>
driver.get('https://www.powderroom.co.kr/rankings/c1100')
AttributeError: 'str' object has no attribute 'get'
プロセスは、どのように私はこのエラーを解決します終了コード1
を終了しましたか?
ありがとうございました。
driver = webdriver.PhantomJS=("c:|phantomjs-2.1.1/windows/bin/phantomjs")
^
が、私はそれが可能になっている等号とは思わない:あなたはタイプミスを持っているよう
#py3.6,pycharm
import re
from bs4 import BeautifulSoup
from selenium import webdriver
import time
driver = webdriver.PhantomJS=("c:|phantomjs-2.1.1/windows/bin/phantomjs")
driver.get('https://www.powderroom.co.kr/rankings/c1100')
i = 0
while i < 8:
i = i + 1
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(1)
bs = BeautifulSoup(driver.page_source, 'lxml')
titles = bs.findAll('div', attrs={'class':'fs-5 tc-gray-1'})
for title in titles:
result = str(title.find_all(text=True))
result = re.sub('[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]', '', result)
print(result)
driver.quit()
私は、プログラムが機能していなかった理由について、エラーが明らかになったとは思わないと思います。 –
印刷 'ドライバ'あなたは理解します –