Python Forum
Webscrapping creating a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Webscrapping creating a dictionary
#1
Hi everyone,

I need to create a function that return a dictionary with information from a website.

The website I must take the information from is:

https://eresearch.fidelity.com/eresearch...ding.jhtml

My function must return the sector name (sector's name are in the right side of the page), enterprise value, return on equity, and dividend yield (this last 3 information are cointained clicking on each sector).

So I suppose I should create a for loop and also use the i.find('a')['href'] method.

It also says the dictionary might return a structure like this:

{'results':{

'Communication Services': {

'enterprise_value': 286.81,

'return_on_equity': 15.82,

'dividend_yield': 3.91},

'Consumer Discretionary': {

'enterprise_value': 279.53,

'return_on_equity': -293.98,

'dividend_yield': 2.32},

'Consumer Staples': {

'enterprise_value': 164.55,

'return_on_equity': -5.36,

'dividend_yield': 2.75}}}

Hope you can help me thinking how I can make it.

Thank you.
Reply
#2
What have you tried? How do you think you could go about solving the problem?

Programming is an exercise in problem solving, so if you want us to do that for you, you're missing the point (and the fun of course!).
Reply
#3
Short desc. how I would do it.

get all names and the hrefs.
build the urls
base_url = 'https://eresearch.fidelity.com/eresearch/goto/markets_sectors/landing.jhtml'
now build the new url
- parse the new url
- find all needed infos
- append needed infos to the dict

run the code in a loop (for) to get all other links / infos

EDIT:
I faced one " issue " while getting all hrefs.
instead of :
"/eresearch/markets_sectors/sectors/sectors_in_market.jhtml?tab=learn&sector=50"

you get:
/eresearch/markets_sectors/sectors/sectors_in_market.jhtml?tab=learn§or=50

remark: -> &sect
Reply
#4
Hello there skylancer, i am looking for help in this code.
Did you got it?! Could you help me on some orientation
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Creating Self Learning Sentiment Dictionary esanjaysaini 1 1,719 Jul-26-2019, 03:27 PM
Last Post: ThomasL

Forum Jump:

User Panel Messages

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