Reputation: 409
I am trying to parse a value called secu
from pages in the format like: https://www.ariva.de/[WKN-input]/historische_kurse
I can find in looking at the source code of the page:
<input type="hidden" name="secu" value="717816" />
E. g.: https://www.ariva.de/A0D9PT/historische_kurse
In the end I would like to store it to a CSV. This is the code I already have, the parse part is missing:
import pandas as pd
# read WKN names from CSV
wkn_list=pd.read_csv('all_wkn_list.csv')
df_output = pd.DataFrame(columns=['wkn', 'secu'])
# loop through WKNs
i=0
for index, row in wkn_list.iterrows():
print(row[0])
url = 'https://www.ariva.de/'+str(row[0])+'/historische_kurse'
# parse secu
secu_parsed = "test"
# store wkn and secu
df_output.loc[i] = [str(row[0])] + [str(secu_parsed)]
i=i+1
# store WKN + secu to CSV
df_output.to_csv('output.csv')
Upvotes: 0
Views: 36
Reputation: 41
You can use the libraries requests and BeautifulSoup for that. Your code would look like this:
import requests
from bs4 import BeautifulSoup
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
input_element = soup.find('input')
There are more ways to find elements based on their tag, class, id... To know more about that, take a look at the BeautifulSoup-documentation.
Upvotes: 1