How
to get my portfolio details from
moneycontrol.com ?
Python
web scraping from moneycontrol.com
Source
code :
Main
Tasks
1.
Getting login URL and parameters
2.
Getting Portofolio details after login
3.
Getting required data using BeautifulSoup
module
2.
Code
Snipet :
LOGIN_URL = "https://accounts.moneycontrol.com/login/index"
URL=
"http://www.moneycontrol.com/bestportfolio/wealth-
management-tool/investments#port_top"
session_requests
= requests.session()
#
Create payload
payload = {
'email' : USERNAME,
'pwd' : PASSWORD ,
}
result
= session_requests.post(LOGIN_URL, data = payload)
newresult
=
session_requests.get("http://www.moneycontrol.com/bestportfolio/wealth-management-tool/investments#port_top")
3.
soup
= bs4.BeautifulSoup(newresult.content,"lxml")
table
= soup.find_all("div", "rightCont")
#print
table
commodittTableRows
= table[0].find_all("div")
cl
= commodittTableRows[0].find_all("p")
for
Bull
./newMoney.py
Net
Worth is 118,445 ▲+72 (+0.06%)
For Bear
Net
Worth is 118,212 ▼-161 (-0.14%)
Source
code :
https://github.com/sterin501/PythonScripts/blob/master/moneycontrol/moneyControlPortfolio.py