小编Aut*_*oft的帖子

Python多线程

我需要从ip列表中提取所有url,我写了这个python脚本,但我有多次提取相同的ip的问题(使用相同的ip创建更多的线程).任何人都可以使用多线程改进我的解决方案吗?

对不起我的英语谢谢大家

import urllib2, os, re, sys, os, time, httplib, thread, argparse, random

try:
    ListaIP = open(sys.argv[1], "r").readlines()
except(IOError): 
    print "Error: Check your IP list path\n"
    sys.exit(1)



def getIP():
    if len(ListaIP) != 0:
        value = random.sample(ListaIP,  1)
        ListaIP.remove(value[0])
        return value
    else:
        print "\nListaIPs sa terminat\n"
        sys.exit(1)

def extractURL(ip):
    print ip + '\n'
    page = urllib2.urlopen('http://sameip.org/ip/' + ip)
    html = page.read()
    links = re.findall(r'href=[\'"]?([^\'" >]+)', html)
    outfile = open('2.log', 'a')
    outfile.write("\n".join(links))
    outfile.close()

def start():
    while True:
        if len(ListaIP) != 0:
            test …
Run Code Online (Sandbox Code Playgroud)

python multithreading

3
推荐指数
1
解决办法
553
查看次数

需要flask-wtforms字段

我如何添加此烧瓶代码所需的标签:

{{ form.youtube_href(type='url', class='form-control') }}
Run Code Online (Sandbox Code Playgroud)

实际输出是:

<input class="form-control" id="youtube_href" name="youtube_href" value="" type="url">
Run Code Online (Sandbox Code Playgroud)

需要这个输出棒给出错误:

<input class="form-control" id="youtube_href" name="youtube_href" value="" type="url" required>
Run Code Online (Sandbox Code Playgroud)

我试过这个蝙蝠给出错误:

{{form.youtube_href(type ='url',class ='form-control','required')}}

python flask flask-wtforms

3
推荐指数
1
解决办法
6399
查看次数

标签 统计

python ×2

flask ×1

flask-wtforms ×1

multithreading ×1