Skip to content
Advertisement

Unable to scrape jpg images link from json

I’m trying to scrape jpg images from each products, every product url saved in csv. Image links are available in json data so try to access json key value. When I try to run code it’s only getting back with all key value in spite of image url link, and second my code only able to scrape last product url in spite of all url saved in csv.

JavaScript

This is the json data. I only want to scrape jpg image link. Below is my code:

JavaScript

I’m trying to scrape all jpg image link and I save csv file having each product url so I want to open csv file and loop each url.

Advertisement

Answer

Few things:

  1. df = pd.DataFrame(detail) should be df = pd.DataFrame(newlist)
  2. You’re loop indentation is off. In fact, why are you looping the urls twice? You get the url from the test.csv (you should just use pandas for that anyway), puting the url into contents list, then loop through that list.

Try this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement