Python BeautifulSoup Looping Through Table Data

Python BeautifulSoup Looping Through Table Data

Very new to Python here. I'm trying to capture some data from this page&nbsp;<a href="https://us.diablo3.com/en/item/helm/" target="_blank" style="color: rgb(0, 89, 153);">this page</a>. I'm trying to get the item name and the item type captured in two lists. I can figure out how to join them into one table later. Any help would be great!

Very new to Python here. I'm trying to capture some data from this page this page. I'm trying to get the item name and the item type captured in two lists. I can figure out how to join them into one table later. Any help would be great!

The lines of code work on their own but the loop doesn't work for me. This produces two lines of code successfully:

import urllib
import bs4 as bs

sauce = urllib.request.urlopen('https://us.diablo3.com/en/item/helm/').read() soup = bs.BeautifulSoup(sauce, 'lxml')

item_details = soup.find('tbody') print(item_details)

item_name = item_details.find('div', class_='item-details').h3.a.text print(item_name)

item_type = item_details.find('ul', class_='item-type').span.text print(item_type)

This repeats the value of the first item_name over and over:

for div in soup.find_all('div', class_='item-details'):
    item_name = item_details.find('div', class_='item-details').h3.a.text
    print(item_name)
    item_type = item_details.find('ul', class_='item-type').span.text
    print(item_type)

This is the output:

Veil of Steel
Magic Helm
Veil of Steel
Magic Helm
Veil of Steel
Magic Helm
Veil of Steel
Magic Helm
Veil of Steel
Magic Helm
Veil of Steel
Magic Helm
Veil of Steel
Magic Helm
...


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Python Development Companies | Hire Python Developers

After analyzing clients and market requirements, TopDevelopers has come up with the list of the best Python service providers. These top-rated Python developers are widely appreciated for their professionalism in handling diverse projects. When...

Python GUI Programming Projects using Tkinter and Python 3

Python GUI Programming Projects using Tkinter and Python 3

Guide to Python Programming Language

Guide to Python Programming Language