A Python package to decode Google News URLs to their original sources.
Project description
Google News Decoder
Google News Decoder is a Python package that can decode Google News links or Google News URLs to their original URLs. It is a simple tool that saves you time and effort. If you find it useful, please support the package by hitting the star on GitHub. Your support helps keep the project going!
Update
- Version 0.1.7:
- New Feature: Added proxy support to handle rate limiting and bypass restrictions.
- Improved: Enhanced error handling with a fallback mechanism for decoding parameters.
- Refined: Optimized
get_decoding_paramsto try decoding viahttps://news.google.com/articlesfirst, falling back tohttps://news.google.com/rss/articlesif needed. - Updated: Reduced occurrences of HTTP 429 (Too Many Requests).
- Removed: Logging functionality for a cleaner codebase.
- Fixed: Resolved time delay issue between requests.
Demo
Installation
You can install this package using pip:
pip install googlenewsdecoder
- You can upgrade this package using pip (upgrade to latest version):
pip install googlenewsdecoder --upgrade
Supported Proxy Formats
-
HTTP/HTTPS Proxy:
- With authentication:
http://user:pass@host:portorhttps://user:pass@host:port - Without authentication:
http://host:portorhttps://host:port
- With authentication:
-
SOCKS5 Proxy:
- With authentication:
socks5://user:pass@host:port - Without authentication:
socks5://host:port
- With authentication:
-
IP and Port Only:
- HTTP:
http://127.0.0.1:8080 - SOCKS5:
socks5://127.0.0.1:1080
- HTTP:
Usage
Here is an example of how to use this package with different decoders:
Using gnewsdecoder
from googlenewsdecoder import gnewsdecoder
def main():
interval_time = 1 # interval is optional, default is None
source_url = "https://news.google.com/read/CBMi2AFBVV95cUxPd1ZCc1loODVVNHpnbFFTVHFkTG94eWh1NWhTeE9yT1RyNTRXMVV2S1VIUFM3ZlVkVjl6UHh3RkJ0bXdaTVRlcHBjMWFWTkhvZWVuM3pBMEtEdlllRDBveGdIUm9GUnJ4ajd1YWR5cWs3VFA5V2dsZnY1RDZhVDdORHRSSE9EalF2TndWdlh4bkJOWU5UMTdIV2RCc285Q2p3MFA4WnpodUNqN1RNREMwa3d5T2ZHS0JlX0MySGZLc01kWDNtUEkzemtkbWhTZXdQTmdfU1JJaXY?hl=en-US&gl=US&ceid=US%3Aen"
try:
decoded_url = gnewsdecoder(source_url, interval=interval_time)
if decoded_url.get("status"):
print("Decoded URL:", decoded_url["decoded_url"])
else:
print("Error:", decoded_url["message"])
except Exception as e:
print(f"Error occurred: {e}")
if __name__ == "__main__":
main()
Using gnewsdecoder with proxy
from googlenewsdecoder import gnewsdecoder
def main():
interval_time = 1 # interval is optional, default is None
proxy = "http://user:pass@localhost:8080" # proxy is optional, default is None
source_url = "https://news.google.com/read/CBMi2AFBVV95cUxPd1ZCc1loODVVNHpnbFFTVHFkTG94eWh1NWhTeE9yT1RyNTRXMVV2S1VIUFM3ZlVkVjl6UHh3RkJ0bXdaTVRlcHBjMWFWTkhvZWVuM3pBMEtEdlllRDBveGdIUm9GUnJ4ajd1YWR5cWs3VFA5V2dsZnY1RDZhVDdORHRSSE9EalF2TndWdlh4bkJOWU5UMTdIV2RCc285Q2p3MFA4WnpodUNqN1RNREMwa3d5T2ZHS0JlX0MySGZLc01kWDNtUEkzemtkbWhTZXdQTmdfU1JJaXY?hl=en-US&gl=US&ceid=US%3Aen"
try:
decoded_url = gnewsdecoder(source_url, interval=interval_time, proxy=proxy)
if decoded_url.get("status"):
print("Decoded URL:", decoded_url["decoded_url"])
else:
print("Error:", decoded_url["message"])
except Exception as e:
print(f"Error occurred: {e}")
if __name__ == "__main__":
main()
Using a for loop to decode multiple URLs
from googlenewsdecoder import gnewsdecoder
def main():
interval_time = 1 # interval is optional, default is None
source_urls = [
"https://news.google.com/read/CBMilgFBVV95cUxOM0JJaFRwV2dqRDk5dEFpWmF1cC1IVml5WmVtbHZBRXBjZHBfaUsyalRpa1I3a2lKM1ZnZUI4MHhPU2sydi1nX3JrYU0xWjhLaHNfU0N6cEhOYVE2TEptRnRoZGVTU3kzZGJNQzc2aDZqYjJOR0xleTdsemdRVnJGLTVYTEhzWGw4Z19lR3AwR0F1bXlyZ0HSAYwBQVVfeXFMTXlLRDRJUFN5WHg3ZTI0X1F4SjN6bmFIck1IaGxFVVZyOFQxdk1JT3JUbl91SEhsU0NpQzkzRFdHSEtjVGhJNzY4ZTl6eXhESUQ3XzdWVTBGOGgwSmlXaVRmU3BsQlhPVjV4VWxET3FQVzJNbm5CUDlUOHJUTExaME5YbjZCX1NqOU9Ta3U?hl=en-US&gl=US&ceid=US%3Aen",
"https://news.google.com/read/CBMiiAFBVV95cUxQOXZLdC1hSzFqQVVLWGJVZzlPaDYyNjdWTURScV9BbVp0SWhFNzZpSWZxSzdhc0tKbVlHMU13NmZVOFdidFFkajZPTm9SRnlZMWFRZ01CVHh0dXU0TjNVMUxZNk9Ibk5DV3hrYlRiZ20zYkIzSFhMQVVpcTFPc00xQjhhcGV1aXM00gF_QVVfeXFMTmtFQXMwMlY1el9WY0VRWEh5YkxXbHF0SjFLQVByNk1xS3hpdnBuUDVxOGZCQXl1QVFXaUVpbk5lUGgwRVVVT25tZlVUVWZqQzc4cm5MSVlfYmVlclFTOUFmTHF4eTlfemhTa2JKeG14bmNabENkSmZaeHB4WnZ5dw?hl=en-US&gl=US&ceid=US%3Aen"
]
for url in source_urls:
try:
decoded_url = gnewsdecoder(url, interval=interval_time)
if decoded_url.get("status"):
print("Decoded URL:", decoded_url["decoded_url"])
else:
print("Error:", decoded_url["message"])
except Exception as e:
print(f"Error occurred: {e}")
if __name__ == "__main__":
main()
Using a for loop to decode multiple URLs with Proxy
from googlenewsdecoder import gnewsdecoder
def main():
interval_time = 1 # interval is optional, default is None
proxy = "http://user:pass@localhost:8080" # proxy is optional, default is None
source_urls = [
"https://news.google.com/read/CBMilgFBVV95cUxOM0JJaFRwV2dqRDk5dEFpWmF1cC1IVml5WmVtbHZBRXBjZHBfaUsyalRpa1I3a2lKM1ZnZUI4MHhPU2sydi1nX3JrYU0xWjhLaHNfU0N6cEhOYVE2TEptRnRoZGVTU3kzZGJNQzc2aDZqYjJOR0xleTdsemdRVnJGLTVYTEhzWGw4Z19lR3AwR0F1bXlyZ0HSAYwBQVVfeXFMTXlLRDRJUFN5WHg3ZTI0X1F4SjN6bmFIck1IaGxFVVZyOFQxdk1JT3JUbl91SEhsU0NpQzkzRFdHSEtjVGhJNzY4ZTl6eXhESUQ3XzdWVTBGOGgwSmlXaVRmU3BsQlhPVjV4VWxET3FQVzJNbm5CUDlUOHJUTExaME5YbjZCX1NqOU9Ta3U?hl=en-US&gl=US&ceid=US%3Aen",
"https://news.google.com/read/CBMiiAFBVV95cUxQOXZLdC1hSzFqQVVLWGJVZzlPaDYyNjdWTURScV9BbVp0SWhFNzZpSWZxSzdhc0tKbVlHMU13NmZVOFdidFFkajZPTm9SRnlZMWFRZ01CVHh0dXU0TjNVMUxZNk9Ibk5DV3hrYlRiZ20zYkIzSFhMQVVpcTFPc00xQjhhcGV1aXM00gF_QVVfeXFMTmtFQXMwMlY1el9WY0VRWEh5YkxXbHF0SjFLQVByNk1xS3hpdnBuUDVxOGZCQXl1QVFXaUVpbk5lUGgwRVVVT25tZlVUVWZqQzc4cm5MSVlfYmVlclFTOUFmTHF4eTlfemhTa2JKeG14bmNabENkSmZaeHB4WnZ5dw?hl=en-US&gl=US&ceid=US%3Aen"
]
for url in source_urls:
try:
decoded_url = gnewsdecoder(url, interval=interval_time, proxy=proxy)
if decoded_url.get("status"):
print("Decoded URL:", decoded_url["decoded_url"])
else:
print("Error:", decoded_url["message"])
except Exception as e:
print(f"Error occurred: {e}")
if __name__ == "__main__":
main()
Thank You
Thank you for installing and using Google News Decoder! I hope this tool saves you time and effort when working with Google News URLs. If you find it useful, please consider hitting the star button on GitHub. If you’d like to contribute or fork the project, your support is greatly appreciated. Thank you for your support!
Credits
- Original script by huksley
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file googlenewsdecoder-0.1.7.tar.gz.
File metadata
- Download URL: googlenewsdecoder-0.1.7.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fcd8fa2aa6a145f84798921aeef0ec45d40bcf5ceebb467742f0efd068d3902
|
|
| MD5 |
fffae25aee7122dd2b166f7d79c3a435
|
|
| BLAKE2b-256 |
9f99d01ae4a3aa30e4d75e7ab6832cb44d79b298a2083b7776f3c8b8830b0aba
|
File details
Details for the file googlenewsdecoder-0.1.7-py3-none-any.whl.
File metadata
- Download URL: googlenewsdecoder-0.1.7-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8be897bb41864a82d81da6e05777d8c795989cf65f14b41e8e772b3f5a8354d
|
|
| MD5 |
9efc11767aa79c920465faefcff9a6c5
|
|
| BLAKE2b-256 |
c5820ff6da895449c6703d24129c4319c5cc2545b0c2c39893f95156b1d841ae
|