Python Forum
Find all values in drop down menu with bs4
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find all values in drop down menu with bs4
#1
Question 
Hi. I want to find all values from the select option tag but I don't know how. I need the value, not the text.
Yeah the URL for my bs4 experiment is a german website for stocks.
If you want to test the code by yourself:
("Monat" = month, "letzten 30 Tage" = last 30 days)
Thats the option menu I mean.

from bs4 import BeautifulSoup
import requests

main_site = requests.get("https://www.ariva.de/ether-kurs/historische_kurse")
soup = BeautifulSoup(main_site.content, 'html.parser')
website = soup.find(attrs={'id':'WEBSEITE'})
select = website.find(attrs={'name':'month'})
option = select.find_all('option')
print(option)
Reply
#2
maybe this

from bs4 import BeautifulSoup
import requests
 
main_site = requests.get("https://www.ariva.de/ether-kurs/historische_kurse")
soup = BeautifulSoup(main_site.content, 'html.parser')
website = soup.find(attrs={'id':'WEBSEITE'})
select = website.find(attrs={'name':'month'})
for option in select.find_all('option'):
    print(option["value"])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  find the sum of a series of values that equal a number ancorte 1 509 Oct-30-2023, 05:41 AM
Last Post: Gribouillis
  Any tips to how to find out values? nevlindan 1 730 Apr-27-2023, 09:14 PM
Last Post: deanhystad
  Loop through values in dictrionary and find the same as in previous row Paqqno 5 1,915 Mar-27-2022, 07:58 PM
Last Post: deanhystad
  Find only the rows containing null values Bhavika 2 2,450 Jun-10-2020, 01:25 PM
Last Post: Bhavika
  Find field name from all possible values kashcode 1 2,120 Apr-22-2020, 06:14 PM
Last Post: deanhystad
  python how to find difference between two values hare 1 6,462 Jan-14-2019, 10:18 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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