python-2.7

Python: Headless mode picks up the older version of chrome

廉价感情. 提交于 2021-02-11 15:10:05
问题 I am trying to automate sending a text message using python & selenium from https://voice.google.com/about . When I run below code, it picks up the lattest version/ instance of google chrome and works fine. But, when I run it headless mode, it uses an older version of google chrome(guessing from screenshot) and gives TimeoutException() exception. It fails while logging in. I checked an element id of sign in box in an IE emulator and it appears to be the same. url = "https://voice.google.com

crawlSpider seems not to follow rule

柔情痞子 提交于 2021-02-11 14:32:22
问题 here's my code. Actually I followed the example in "Recursively Scraping Web Pages With Scrapy" and it seems I have included a mistake somewhere. Can someone help me find it, please? It's driving me crazy, I only want all the results from all the result pages. Instead it gives me the results from page 1. Here's my code: import scrapy from scrapy.selector import Selector from scrapy.spiders import CrawlSpider, Rule from scrapy.http.request import Request from scrapy.contrib.linkextractors.sgml

What does '__main__' mean in the output of type() [closed]

白昼怎懂夜的黑 提交于 2021-02-11 14:21:20
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question If I create a class as below, and check the type of the object, I get the following output. My question is what does __main__ mean here? class Student(object): pass >>>a = Student() >>>type(a) <class '__main__.Student'> There is another question, if I check the

What does '__main__' mean in the output of type() [closed]

徘徊边缘 提交于 2021-02-11 14:20:35
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Improve this question If I create a class as below, and check the type of the object, I get the following output. My question is what does __main__ mean here? class Student(object): pass >>>a = Student() >>>type(a) <class '__main__.Student'> There is another question, if I check the

In Python 2.7 why are strings written faster in text mode than in binary mode?

那年仲夏 提交于 2021-02-11 14:16:37
问题 The following example script writes some strings to a file using either "w" , text, or "wb" , binary mode: import itertools as it from string import ascii_lowercase import time characters = it.cycle(ascii_lowercase) mode = 'w' # mode = 'wb' # using this mode takes longer to execute t1 = time.clock() with open('test.txt', mode) as fh: for __ in xrange(10**7): fh.write(''.join(it.islice(characters, 0, 50))) t2 = time.clock() print 'Mode: {}, time elapsed: {:.2f}'.format(mode, t2 - t1) With

wtforms returns only None

▼魔方 西西 提交于 2021-02-11 13:56:09
问题 I have the following HTML, CSS and JS code. However, when I use the search from the top right side and press enter. Flask only get "None" and what was typed in search. This is the route for the search: @app.route("/quick_search/", methods=("GET", "POST")) @app.route("/quick_search/<property_id>") def quick_search(property_id=None): form = QuickSearch() print "???", form.propert_name.data and this form class: from flask.ext.wtf import Form from wtforms import SelectField, StringField,

python using set to create list of elements that only appear once [duplicate]

廉价感情. 提交于 2021-02-11 12:50:34
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How can I make my code be a set? python takes list and returns only if negative value also exists using set Basically I have a huge list: # with (n) being a number in the hundreds of thousands or millions def big_list(n): return [ randrange(n) for i in range(n) ] What I need to do is create a new list containing only the elements of big_list(n) that appear once using set . I'm really stuck so anything that could

CSV Reader different outputs on Ubuntu and Windows - Python [duplicate]

孤者浪人 提交于 2021-02-11 12:36:12
问题 This question already has answers here : Python 2 CSV writer produces wrong line terminator on Windows (3 answers) Closed 4 years ago . I have a file called Some.csv which has a field (column) which has values like 1000, 2000, .... 39000. I wanted only the files with 39000 so I wrote the following python script import os import csv with open('Somenew.csv', 'w') as fw: writr = csv.writer(fw, delimiter=',') with open('Some.csv','r') as fr: reader = csv.reader(fr, delimiter = ',') for row in

User prompts with multithreading

不羁的心 提交于 2021-02-11 12:17:05
问题 I have a couple threads running at once, doing things in the "background", but then the program reaches a point where it needs user input for all the threads to continue. Below is what I have written, and it works, but it seems inefficient and I'm not sure how else to do it as this is my first experience with multi-threading. global userPromptFlag = 1 # first thread to reach this condition prompts the user for info if (userPromptFlag == 1): userPromptFlag = 0 self.userPrompts() else: # other

Number of online people in django [closed]

独自空忆成欢 提交于 2021-02-11 12:15:40
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Improve this question I have a website and i want to find number of online users in my website(All of users logged to their account or not): And when they get offline or close page the number of online users get update: How can i do that?is there any library to do that? 回答1: You can