2021年3月7日星期日

How to turn multiple scraped urls into a single observation?

I am currently scraping an online store to gather data on all its products. This includes the urls for the multiple images that each product has. The code so far is as follows:

for image in subsoup.find_all('a',{'class':'thumb-link'}):    url.append(image.find('img').get('src'))  

This yiedls a list of urls for a single product, which is then added to a dictionary key:

'URL': ['url1', 'url2', 'url3', 'url4']  

What I want to know is how to turn the multiple links for each product into an individual observation which occupies only one row. This way, when I turn the dictionary into a DataFrame and export it as csv, all columns will have the same length.

https://stackoverflow.com/questions/66524170/how-to-turn-multiple-scraped-urls-into-a-single-observation March 08, 2021 at 12:07PM

没有评论:

发表评论