Python Forum
Can python open a hyperlink?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can python open a hyperlink?
#1
Hello all,

So I am new to Python and coding in general, and while I am still teaching myself some of the basics I was curious about this question. Can python open a hyperlink from a document or a webpage and if it can what kind of code should I be using? I have looked on google for an answer and I couldn't find one and I couldn't find a thread on here about it (if there is one and I missed it, I apologize and would greatly appreciate being pointed in its direction). I would appreciate any information I can get and I am sorry if this is the wrong thread forum to be posting this question in.
Reply
#2
Clicking a link on s page makes an HTTP request to the URL. Yes, you can make HTTP requests in Python and process the responses. There are likely a number of HTTP clients you can use, but a popular one is Requests: https://docs.python-requests.org/en/master/.
Reply
#3
import antigravity
This Module uses webbrowser.open("url") to open a new tab in a browser.
https://docs.python.org/3/library/webbrowser.html

If you're using Windows, you can additionally use https://docs.python.org/3/library/os.html#os.startfile

New processes can be started with subprocess.run().

The difference is, that webbrowser.open sends a url to your default browser.
os.startfile starts the associated program belonging to the file extension. For example .docx will open Word. But this works only on Windows.

subprocess.run() starts a new process, where you have to define the executable.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
(Apr-28-2021, 08:14 AM)1stTimeCoding Wrote: I have looked on google for an answer and I couldn't find one and I couldn't find a thread on here about it (if there is one and I missed it, I apologize and would greatly appreciate being pointed in its direction)
I can hardly believe any of this. Also note there is Web Scraping & Web Development section of the forum
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Word, adding a hyperlink from a bookmark using Python mart79 1 2,308 Jan-14-2021, 08:41 PM
Last Post: Larz60+
  remove underline from hyperlink in excel SriMekala 0 1,874 Jul-25-2019, 01:58 PM
Last Post: SriMekala
  How to add hyperlink to existing Excel file SriMekala 2 12,075 Jul-25-2019, 02:28 AM
Last Post: SriMekala

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020