當我試圖擺脫「?」後面的所有內容時,出現錯誤在一組刮鏈接:刪除「?」後的所有內容python
代碼:
from selenium import webdriver
import pandas as pd
import time
from datetime import datetime
from collections import OrderedDict
import re
browser = webdriver.Firefox()
browser.get('https://www.kickstarter.com/discover?ref=nav')
categories = browser.find_elements_by_class_name('category-container')
category_links = []
for category_link in categories:
category_links.append((str('https://www.kickstarter.com'),
category_link.find_element_by_class_name('bg-white').get_attribute('href')))
print(category_links)
for i in category_link:
category_links2 = re.sub('?$', '', category_links)
print(category_links2)
錯誤:
TypeError: 'FirefoxWebElement' object is not iterable
什麼行會拋出錯誤? – SeeDerekEngineer