Web scraping 从csv文件加载URL列表,并使用Beautifulsoup刮取标题标记

Web scraping 从csv文件加载URL列表,并使用Beautifulsoup刮取标题标记,web-scraping,beautifulsoup,Web Scraping,Beautifulsoup,我正在尝试使用Beautifulsoup从csv中的URL列表中刮取标题,但它不会在每次遇到不起作用的URL时都继续。有人能帮我吗 下面是我使用的代码 #!/usr/bin/python # -*- coding: utf-8 -*- from bs4 import BeautifulSoup #required to parse html import requests #required to make request with open('df_urls.csv','r') as f:

我正在尝试使用Beautifulsoup从csv中的URL列表中刮取标题,但它不会在每次遇到不起作用的URL时都继续。有人能帮我吗

下面是我使用的代码

#!/usr/bin/python
# -*- coding: utf-8 -*-

from bs4 import BeautifulSoup #required to parse html
import requests #required to make request

with open('df_urls.csv','r') as f:
    csv_raw_cont=f.read()

split_csv=csv_raw_cont.split('\n')

split_csv.remove('')

#specify separator
separator=";"

#iterate over each line
for each in split_csv:
  
    url_row_index=0 
   
    url = each.split(separator)[url_row_index] 
    
    html=requests.get(url).content
    
    soup = BeautifulSoup(html)
    
    print(soup.title.string)

你试过
汤.title.text
吗??或者URL是正确的URL是正确的,但有些是不可访问的。我想得到列表中从上到下的所有结果,如果可能的话,非工作URL可以得到例如:“不工作”。