Hi there
I am trying to get pages that containg special word after posting vales.
how can i make this script work in threading about 10 thread ..
below is my code
# -*- coding: cp949 -*-
import csv, sys
import urllib
import urllib2
import time
import string
import threading
URL = sys.argv[2]
def get_page(no,year):
try:
url = sys.argv[2]
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
values = {no_value : no,year_value : year }
data = urllib.urlencode(values)
headers = { 'User-Agent' : user_agent }
req = urllib2.Request(url, data, headers)
for line in urllib2.urlopen(req):
if sys.argv[3] in line:
print no, year
except:
pass
f = open(sys.argv[1], 'r')
for line in f:
no, year= line.strip().split(':')
get_page(no,year)
# I run this script like below
# get.py list.txt http://www.google.com/post.php "keyword"
# if the pages contains sys.argv[3]
it print out "no" and "year" to the promtpt
# list.txt contains like this (no:year)
1:1999
2:2000
3:2001
4:2002
5:2003
#####################
help me to get this script work in thread mode
thanks...
I am trying to get pages that containg special word after posting vales.
how can i make this script work in threading about 10 thread ..
below is my code
# -*- coding: cp949 -*-
import csv, sys
import urllib
import urllib2
import time
import string
import threading
URL = sys.argv[2]
def get_page(no,year):
try:
url = sys.argv[2]
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
values = {no_value : no,year_value : year }
data = urllib.urlencode(values)
headers = { 'User-Agent' : user_agent }
req = urllib2.Request(url, data, headers)
for line in urllib2.urlopen(req):
if sys.argv[3] in line:
print no, year
except:
pass
f = open(sys.argv[1], 'r')
for line in f:
no, year= line.strip().split(':')
get_page(no,year)
# I run this script like below
# get.py list.txt http://www.google.com/post.php "keyword"
# if the pages contains sys.argv[3]
it print out "no" and "year" to the promtpt
# list.txt contains like this (no:year)
1:1999
2:2000
3:2001
4:2002
5:2003
#####################
help me to get this script work in thread mode
thanks...
Last edited: