guys i want to make a script like this
1.Open a text file containing urls
2.send a web request to all url one by one (post some data also in field of "name=" )
3.check the response of the sent page and if it fulfills condition open new text file and add that url to that new made file
4.loop the whole code for all urls in the txt file opened in 1
any help guys
4 replies to this topic
#1
Posted 11 August 2011 - 05:48 AM
|
|
|
#2
Posted 11 August 2011 - 11:23 AM
I have no idea what the condition is, but this is a relatively basic task. Have you learned much Python? Opening a file is just as easy as using the open() function, then using readlines() to get the whole content of the file in a list of lines. You're rather nebulous about what web request you mean, just getting the URL contents itself (IE getting the HTML)? Could you please be more specific as to what you're trying to do?
Something like this:
Something like this:
handle = open("urlfile.txt", "r")
outfile = open("output.txt", "w")
for line in handle.readlines():
url_content = urllib.urlopen("{url}#name={name}".format(url = line[:-1], name = some_name))
# used [:-1] in line to remove the ending \n from line for the url, else you'd have bad formatting.
if (passed_condition(url_content)):
outfile.write(line)
That code should get the contents of any URL and pass, as a URL argument, a name assigned to some_name. Again, I have no idea what passed_condition is, so I just left it as another function. Does this help, or is it something else you want?
Wow I changed my sig!
#3
Posted 12 August 2011 - 01:08 AM
no m new to python my first code every i and i can`t understand where i have to make changes to adjust the condition like i want to match the text "Signout" where i can fix that part????
#4
Posted 12 August 2011 - 10:33 AM
This is your first attempt at programming in Python? Well, this is going to be a little more challenging then... what do you know about Python, are you familiar with control loops, creating objects, passing arguments to functions, etc.? If not, and you really need this program, I suggest you find someone who can write it for you for payment. If this is just a learning exercise, I think you should consider something a bit simpler until you understand the basic concepts of Python and can navigate multi-file programs.
Wow I changed my sig!
#5
Posted 14 August 2011 - 11:15 AM
A Fibonacci sequence generator is usually a good one to get started with, after the obligatory Hello World.
sudo rm -rf /
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









