Hi all, python newbie here. I want to write code to scrape several newspapers for articles on a specific subject, output the results of the scraping on a .csv file and then analyse said .csv file. Figuring out the scraping part has been quite a headache, and as such I would like to get some direction from the Python Discord hivemind if that is possible. My initial approach was to use 'requests' to scrape a tag page HTML (e.g. National), and that worked, but then I realised I hit a dead end as this approach only took me so far (website would only display say latest 20 articles in page, with no pagination mechanism or 'show more' buttons; if I asked requests to return more pages of articles, it returned multiple copies of the same articles). My current thinking, based on this previous realisation and further research, is that I'm better off scraping search results pages, but requests does not seem to work there. How could I go on about tackling this problem of mine? What steps should I take? And how could I make sure that each scrape from each newspaper archive feeds into the same dataframe? All and any help is greatly appreciated.
#๐ Scraping newspaper websites - advice needed
22 messages ยท Page 1 of 1 (latest)
@winged cave
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
aka dont help with scraping if u cant show u are allowed but if u are allowed u should be haveing an api and useing that aint scraping
Thanks for responding @flat geode and apologies for triggering rule 5.
I do not intend to scrape websites that do not allow it but understand I need to demonstrate this so I can ask this question publicly.
websites usally dont allow it or provide an api
can u give me a link to the site?
Here is an example https://www.thenational.scot/robots.txt
I take it I would be triggering in this specific case this one --> Disallow: /search/*?
brother thats not even a url its a uri it points to a file not to an html
I know - I am just asking if this is an indication of their policy on scraping sorry
The website is this https://www.thenational.scot/
Scottish news, politics, opinion, culture and features you can trust from Scotland's only pro-independence newspaper.
Appreciate you looking into this!
according to the robots.txt /news/ is allowed
Thanks 0x - this is the bit I am trying to scrape, and not even a massive amount, a couple of months more or less. I intend to be very much guided by what each website allows.
https://www.thenational.scot/news/rss/ they have rss available which provides access to 53 articles in total updates daily I assume
So I hadn't actually considered this before - I seem to be able to access the RSS of a number of publications. I assume this is refreshed / would need to be scraped daily?
yes, you could do further testing to see if they are consistent on updating the rss
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.