Python script click link
Not a best way, but works. Is it what you need? (Python 2.7)
```import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect((‘your_first_host’, 80))
mysock.send(‘GET your_first_page HTTP/1.0\n\n’)
while True:
data = mysock.recv(512)
if ( len(data) < 1 ) :
break
print data;
mysock.close()
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect((‘your_second_host’, 80))
mysock.send(‘GET your_second_page HTTP/1.0\n\n’)
while True:
data = mysock.recv(512)
if ( len(data) < 1 ) :
break
print data;
mysock.close()```
It’s okay I found a upper language version to solve it, I’ve just use webbrowser import as it follow :
```
import requests
import webbrowser
from datetime import datetime
def get_request(result):
#conn = requests.get(“http://challenge01.root-me.org/programmation/ch1/ep1_v.php?result=” + str(result))
#print conn.status_code
webbrowser.open(“http://challenge01.root-me.org/programmation/ch1/ep1_v.php?result=” + str(result))
def suite(n):
start = datetime.now()
webbrowser.open(‘http://challenge01.root-me.org/programmation/ch1/’)
Un = 861
Unp1 = 861
for x in range(0, n):
Un, Unp1 = Unp1, ((-33 + Un) - (x * 34))
print datetime.now()-start
print “Result :”, Unp1
get_request(Unp1)
suite(662522)
```
But Ididn’t noticed that the source code is ramdomly generated !
So I need to take the source code Of the opened page . How can I do it using python?
But your code is also good btw.
Dloser
Sorry I’m french , sorry for my bad English , actually I try to do the following challenge :
http://www.root-me.org/en/Challenges/Programming/Arithmetic-progression-18
Seems like that challenge similar to https://www.hackthis.co.uk/levels/coding/1
As you are here now, try to solve this chalenge first.
You are both right x )
I’ve already done those but it seems I ’ve made something wrong.
I can code harder things I guess x ) don’t want to waste my time on it x )
And yes the 2 imports which will be useful here are : webbrowser and urllib2 , I will check them out , I already found a way.
Thank you guys !
I will shut the thread now ; ]
Perhaps one of the best material on the subject: Using Python to Access Web Data on Coursera
https://www.coursera.org/learn/python-network-data/lecture/TdznM/understanding-html