It is currently Tue Aug 22, 2017 12:44 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Apr 04, 2017 1:41 pm 

Joined: Tue Apr 04, 2017 1:33 pm
Posts: 1
I've been using vpngate.net for sometime and I decided to make a script that deletes all the .ovpn files in the current directory, runs a python script that downloads a new file and runs it.
My problem occurs in this python script. I use web scraping to download the homepage (http://vpngate.net), then it selects all vpn's download urls, stores them in a list and chooses one randomly. Everything's fine until here. The problem is that, every time I open "http://vpngate.net/en/[choosen_vpn]" it redirects to the homepage.
What can I do to solve this?

Code here for anyone interested:

import requests
from bs4 import BeautifulSoup
from random import randint
import time
import sys
import webbrowser

url = "http://vpngate.net"
print("[+] Connecting to vpngate.net...")
page = requests.get(url)
if page.status_code == 200:
print("[+] Connection established.")
else:
print("[-] Connection went wrong\nQuiting.")
time.sleep(1)
sys.exit()

soup = BeautifulSoup(page.content, "html.parser")

open = []
print("[+] Sorting vpn's...")
for link in soup.find_all("a"):
if "do_openvpn" in str(link):
open.append(str(link["href"]))

print("[+] Choosing random vpn...")
number = randint(0, len(open))

print("\n[+] Connecting to vpn's url...")
page2 = requests.get(url + "/en/" + open[number])
soup2 = BeautifulSoup(page2.content, "html.parser")
print("[ ] Checking if url didn't redirect to homepage...")
while soup2.find_all("title")[0] == soup.find_all("title")[0]:
print("[-] Url redirected to homepage.")
print("[+] Trying again...")
number = randint(0, len(open) - 1)
page2 = requests.get(url + "/en/" + open[number])
soup2 = BeautifulSoup(page2.content, "html.parser")

webbrowser.open(url + "/en/" + open[number])


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Return to www.softether.org