Python Forum
BeautifulSoup Showing none while extracting image url
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BeautifulSoup Showing none while extracting image url
#1
Hello Everyone!
I am trying to extract images url from gallery images on woocommerce website, but its showing none when I tried through csv file. Also I want extract variation color. Here is my code
import csv

from bs4 import BeautifulSoup
import requests
from urllib.request import urlretrieve
import os
import urllib
import pandas as pd

data_dic = {}
with open('D:/Scrapping/Newfolder/Urls.csv') as csvFile:
    data = csv.DictReader(csvFile)
    for row in data:
        request = requests.get(row['url'])
        soup = BeautifulSoup(request.content, 'html.parser')
        print(soup.prettify)
for images in soup.find_all('div', {'class': 'woocommerce-product-gallery__image'}):
    print(images.find('a')['href'])
here is output

Output:
PS D:\Scrapping> d:; cd 'd:\Scrapping'; & 'C:\Users\Asim\AppData\Local\Programs\Python\Python39\python.exe' 'c:\Users\Asim\.vscode\extensions\ms-python.python-2021.9.1230869389\pythonFiles\lib\python\debugpy\launcher' '59785' '--' 'd:\Scrapping\ztest.py' PS D:\Scrapping>
Larz60+ write Sep-20-2021, 12:24 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Extracting the Address tag from multiple HTML files using BeautifulSoup Dredd 8 1,425 Jan-25-2021, 12:16 PM
Last Post: Dredd
  Image Scraper (beautifulsoup), stopped working, need to help see why woodmister 9 1,198 Jan-12-2021, 04:10 PM
Last Post: woodmister
  not getting image src in my BeautifulSoup csv file farhan275 11 1,245 Sep-14-2020, 04:52 PM
Last Post: buran
  BeautifulSoup: Error while extracting a value from an HTML table kawasso 3 1,531 Aug-25-2019, 01:13 AM
Last Post: kawasso

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020