Script downloading file from filesonic
Could somebody please advise me on how I could write a Python script to do these things?
- Change my IP address to some random proxy address.
- Download and display the captcha image and show me the prompt where I can write captcha characters.
- Download the main file.
The script should have one input parameter (the address is similar to one of these):
http://www.filesonic.com/file/212720521/Ubuntu.11.04.part1.rar
http://www.filesonic.com/file/212720541/Ubuntu.11.04.part2.rar
It would be called开发者_如何学JAVA twice as follows:
python dlsonic.py http://www.filesonic.com/file/212720521/Ubuntu.11.04.part1.rar
python dlsonic.py http://www.filesonic.com/file/212720541/Ubuntu.11.04.part2.rar
Here's some basic Python to get you started:
import urllib2
response = urllib2.urlopen('http://www.example.com/')
html = response.read() # This is what is read from the file. In your case,
# it'll only read the contents of the webpage.
To change your IP address, you can use some Linux commands to accomplish this (assuming you're using ethernet here):
ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up
ifconfig eth0
And with Python, you can run these with os.system()
:
import os
os.system('ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up')
os.system('ifconfig eth0')
And to handle command line arguments, like python foo.py bar foo bar bar
:
import sys
print sys.argv
As for dealing with the CAPTCHA, that will be tough. Are you sure you can't just do this manually?
精彩评论