我可以提取代码并将其写入CSV,但是当导入excel时,只有html的第一行显示在excel文件中。它确实可以在Google表格中正常运行。我确定其中有导入的换行符,但在写入CSV之前我不知道如何剥离它。感谢您提供的所有帮助。
我的代码。
def grabAddress():
element = browser.find_elements(By.XPATH, '//*[@id="memberDetail"]/section/div/div[1]/div[3]/p[2]/strong')
strings = []
for x in element:
strings.append(x.text)
splitstrings = "".join(strings)
address.append(splitstrings)
return 0
with open(r"C:\bnicsv\compiled.csv", "w", newline ="") as compiledCSV:
writecompiledtoCSV = csv.writer(compiledCSV, delimiter=",")
writecompiledtoCSV.writerows(compiled_list)
HTML我正在拉...
<strong>
Jack Jackson<br>
Jacks Jewelers<br>
1985 East End Blvd.<br>
St. Paul Park, MN 55555
</strong>