下面的代码旨在获取视频课程的标题。好吧,它找到了,但我无法将输出写入文本文件。
from selenium import webdriver
f=("output.txt", "a")
browsing_1 = webdriver.Firefox(executable_path="C:\\Tester\\geckodriver.exe")
browsing_1.get("https://channel9.msdn.com/Niners/JeffKoch/Posts?page=170")
testing_texts = browsing_1.find_elements_by_xpath("//div[@class='seriesTitle']")
for namess in testing_texts:
print(namess.text)
当我使用这个 f.write(names) 它给出以下内容:
Traceback (most recent call last):
File "C:\Tester\trial83.py", line 11, in <module>
f.write(names)
AttributeError: 'tuple' object has no attribute 'write'
无论如何,我可以附加文件并在其中包含以下输出吗?
Link:"https://channel9.msdn.com/Niners/JeffKoch/Posts?page=170"
System Center 2012 R2 Infrastructure Provisioning and Management
Core Solutions of Exchange Server 2013
Core Solutions of Exchange Server 2013
Core Solutions of Exchange Server 2013
Core Solutions of Exchange Server 2013
Core Solutions of Exchange Server 2013
Core Solutions of Exchange Server 2013
Core Solutions of Exchange Server 2013
Windows Server 2012 R2 Storage
Windows Server 2012 R2 Storage
Windows Server 2012 R2 Storage
Windows Server 2012 R2 Storage