Here's some code I made for url extracting and requests.

Sort:
Avatar of DefenderPug2

from urlextract import URLExtract
import requests
link = input("link: ")
scrape = requests.get(link).text
urls = URLExtract().find_urls(scrape)
counter = 0
for i in range(len(urls)):
  counter += 1
  print("\n>link {0}".format(counter))
  print(urls[i])
link_open = int(input("open link -> "))
url = urls[link_open - 1]
print(url)
x = requests.get(url)
print(x.text)

Just to sort out any confusion, the indentation is in counts of 2 instead of 5. I use 2 space indentation for my code because it's just what I like it set to. I use the repl IDE for my coding environments if you want to check it out for yourself. Criticize my code as you'd like.

Avatar of DefenderPug2

There isn't a lot of logic added for if you return an incorrect prompt. Just rerun the program and do it correctly. Add on to the code as need be.

Avatar of DefenderPug2
stopvacuuming wrote:

what

can you um...clarify what you're asking?

Avatar of Gymstar

😂

Avatar of Gymstar
DefenderPug2 wrote:

 

from urlextract import URLExtract
import requests
link = input("link: ")
scrape = requests.get(link).text
urls = URLExtract().find_urls(scrape)
counter = 0
for i in range(len(urls)):
  counter += 1
  print("\n>link {0}".format(counter))
  print(urls[i])
link_open = int(input("open link -> "))
url = urls[link_open - 1]
print(url)
x = requests.get(url)
print(x.text)

 

Just to sort out any confusion, the indentation is in counts of 2 instead of 5. I use 2 space indentation for my code because it's just what I like it set to. I use the repl IDE for my coding environments if you want to check it out for yourself. Criticize my code as you'd like.

I have no clue how to do this

Avatar of DefenderPug2
Gymstar wrote:
DefenderPug2 wrote:

 

from urlextract import URLExtract
import requests
link = input("link: ")
scrape = requests.get(link).text
urls = URLExtract().find_urls(scrape)
counter = 0
for i in range(len(urls)):
  counter += 1
  print("\n>link {0}".format(counter))
  print(urls[i])
link_open = int(input("open link -> "))
url = urls[link_open - 1]
print(url)
x = requests.get(url)
print(x.text)

 

Just to sort out any confusion, the indentation is in counts of 2 instead of 5. I use 2 space indentation for my code because it's just what I like it set to. I use the repl IDE for my coding environments if you want to check it out for yourself. Criticize my code as you'd like.

I have no clue how to do this

its just using the functions from the modules and a little indexing magic. Simple enough to only use one "for" loop.