Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Python获得不同列中的交替行web抓取?_Python_Python 3.x_Web Scraping - Fatal编程技术网

如何使用Python获得不同列中的交替行web抓取?

如何使用Python获得不同列中的交替行web抓取?,python,python-3.x,web-scraping,Python,Python 3.x,Web Scraping,这是我的代码: records=[] for artist_name in artist_name_list_items: names = artist_name.contents print(names) records.append((names)) 这是已编写代码的输出,但当我将其添加到数据框中时,它将显示在单个列中 ['Star Wars: Episode VII - The Force Awakens'] ['2015'] ['Avengers: Endgam

这是我的代码:

records=[]
for artist_name in artist_name_list_items:
    names = artist_name.contents
    print(names)
    records.append((names))
这是已编写代码的输出,但当我将其添加到数据框中时,它将显示在单个列中

['Star Wars: Episode VII - The Force Awakens']
['2015']
['Avengers: Endgame']
['2019']
['Avatar']
['2009']
['Black Panther']
['2018']
['Avengers: Infinity War']
['2018']
['Titanic']
['1997']
['Jurassic World']
['2015']
['The Avengers']
['2012']
['Star Wars: Episode VIII - The Last Jedi']
['2017']
['Incredibles 2']
['2018']

请帮我整理一下。谢谢

你好,欢迎光临。我看到你用
网页抓取
标记了这一点,但问题似乎不是指任何网页抓取技术。这仍然相关吗?如果没有,我将删除该标记。另外,您确定这是此输出的正确查询吗?查询似乎只与
artist_name
一起工作,但您的数据输出的是标题和年份。快速浏览时,您的查询似乎没有映射到您的输出。正在修复问题和一些语法的格式。您可能需要重新检查您的抓取。页面中每个数据的选择器应该有所不同。从源头上分离出来。