简体   繁体   中英

Is there a way to find the country about which a news article was written in Python?

I'm trying to find the country for which a news article was written.

I'm not trying to find the country in which the article was written, but rather the country that the headline occurred in. For example, if The Guardian wrote about United States, I would want the Python code to return "United States" and not "UK".

Thus far, I have tried to use the pygooglenews library to get the headline, but I'm trying to see if I can get the country, too.

If you are talking about a website, your best bet is using beautifulsoup in python to extract the html information and finding it that way by parsing it.

You can get every information using beautiful soup, writing a parser to detect the countries is up to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM