Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When scrape.py is run , It throws errors like Error opening url!! #1

Open
keerthankumar opened this issue Apr 17, 2018 · 17 comments
Open

Comments

@keerthankumar
Copy link

Is it still possible to scrape data from moneycontrol through this script in April 2018 or something changed in a website that script doesn't valid anymore?

@keerthankumar
Copy link
Author

Hello Any response ?

@vintageplayer
Copy link
Member

vintageplayer commented Apr 20, 2018

The script is executing correctly. Could you be more specific about the problem? "Error Opening URL!!" (Line 40 in the script) is mainly thrown due to timeout/connection issues. Also, it has been tested on python3 only, older versions of requests library might be an issue.

@keerthankumar
Copy link
Author

keerthankumar commented Apr 21, 2018

Thanks for responding..

I was debugging from my end.. I could zero in that error is because of the signal module in windows platform. Which does not have attributes such as SIGALRM etc.?

Please tell me when u ran this did u ran on Unix platform or windows?

@keerthankumar
Copy link
Author

one more question,
why do we require time_limit function ?

@vintageplayer
Copy link
Member

vintageplayer commented Apr 22, 2018

It was tested on unix platform. Time function is there to handle request timeouts automatically. You can comment out the lines if required. The function could be simplified to:

def get_response(aurl):
	hdr				= {'User-Agent':'Mozilla/5.0'}

	try: 
		content 				= requests.get(aurl,headers=hdr).content
	except Exception:
		print("Error opening url!!")

	return content

@keerthankumar
Copy link
Author

Will try this in windows and let you know.

Btw are you aware the legality of this code ? I mean is scraping data from Moneycontrol legal ?

@vintageplayer
Copy link
Member

The robot.txt file disallows crawling certain endpoints, none of which this script accesses.
The terms of usage disallows sharing/broadcasting of site data (not specifically mentioning crawling/scraping). Also, it emphasises on stock call information.
This script is getting only the Profit&Loss and Balance Sheet information, which supposed to be public information for any publicly traded company.
To my best knowledge, there shouldn't be any issue with legality. Please let me know incase anything contradictory is found.

@jhawakshay
Copy link

Hi,

Does it work in Google chrome also? As, I am running the script, I am facing an error 'Access is denied'

@vintageplayer
Copy link
Member

Hi,

Does it work in Google chrome also? As, I am running the script, I am facing an error 'Access is denied'

This script is browser independent. There is no browser automation required to run it. So Google chrome is irrelevant to running the script. This will run in the terminal python scrape.py or use an IDE.
Is that returning an 'Access is denied'?

@chinkoopataka
Copy link

Hi KeerthanKumar

Were you able to run it on Windows? I am getting the same "Error Opening URL" on spyder IDE on win 10. Please assist

@vintageplayer
Copy link
Member

Hi, This was created a while back, maybe the endpoints have changed. Let me know the features required, maybe I can still patch it free time.

@chinkoopataka
Copy link

If you could please patch it, it would be awesome

@chinkoopataka
Copy link

For each company, it is saying "Data on ABC company doesnt exist anymore" where ABC is every company.
And what I don't understand is why is the program starting from the companies starting from letter 'H'

@vintageplayer
Copy link
Member

For each company, it is saying "Data on ABC company doesnt exist anymore" where ABC is every company.
And what I don't understand is why is the program starting from the companies starting from letter 'H'

for link in links[8:]:

Is starting from index 8. Thus it's always starting with H.

@chinkoopataka
Copy link

Thanks, Didn't see it before.
Do you think you can look into this code dude?

@khashyapk
Copy link

For each company, it is saying "Data on ABC company doesnt exist anymore" where ABC is every company.
And what I don't understand is why is the program starting from the companies starting from letter 'H'

for link in links[8:]:

Is starting from index 8. Thus it's always starting with H.

For all the companies, it says data doesn't exist anymore. Please take a look when you can and update

@tangoAnkur
Copy link

Data on 'G K P Printing' doesn't exist anymore. even If I make a position change for the same!
Kindly let me know if any clue on the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants