Форум сайта python.su
[code python]
def get_holidays(country_item):
session = requests.Session()
getPage = session.get(country_item['href'])
pageHtml = html.fromstring(getPage.text)
getAllBlock = pageHtml.cssselect(".holidayweek>table>tbody>tr>td>ul>li>a")
lists = []
for item in getAllBlock:
href = 'http://www.calend.ru/' + item.attrib['href']
title = item.text
country = country_item['coutry']
[/code]
getAllBlock = pageHtml.cssselect(".holidayweek>table>tbody>tr>td>ul>li>a")
# -*- encoding: utf-8 -*- from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor from scrapy.contrib.spiders import CrawlSpider, Rule from scrapy.selector import HtmlXPathSelector from job.items import JobItem import time class JobSpider(CrawlSpider): name = 'superjob' allowed_domains = ['superjob.ru'] start_urls = [ 'http://www.superjob.ru/vacancy/search/?t%5B0%5D=4&sbmit=1&period=7' ] rules = [ Rule(SgmlLinkExtractor(allow='/vacancy/search/?', restrict_xpaths=( u'//a[@class="h_border_none"]/<span>следующая</span>')), callback='parse', follow=True), ] def parse(self, response): hxs = HtmlXPathSelector(response) titles = hxs.select( '//*[@id="ng-app"]/div[2]/div/div[2]/div/div[1]/div[2]/div/div/h2/a') items = [] count = 0 for title in titles: item = JobItem() item['title'] = title.select('//h2/a/text()').extract() items.append(item) count += 1 name_time_file = time.strftime("%Y-%m-%d-%H-%M") data_file = open('{}.csv'.format(name_time_file), 'w') data_file.write(str(count)) data_file.close() # return items
c:\python27/python c:\python\websocket2.py
<script language="javascript" type="text/javascript"> var edit=0; $( "#target" ).click(function() { if(edit==1){ $('li #target').text('Редактировать взвешиванием'); edit=0; }else{ $('li #target').text('Редактировать в ручную'); edit=1 } }); var wsUri = "ws://127.0.0.1:9999"; var output; function init() { output = $("#id_choice_text"); //$("#id_choice_text").val("Логин"); testWebSocket(); } function testWebSocket() { var websocket = new WebSocket(wsUri); websocket.onmessage = function (evt) { onMessage(evt) }; } function onMessage(evt) { writeToScreen( evt.data.substring(1, 6)//'<li>Напряжение на входе: <span style="color: red;">' + evt.data.substring(1,6) + '</span></li>' //'<li>Аварийное напряжение: <span style="color: red;">' + evt.data.substring(7,12) + '</span></li>'+ //'<li>Напряжение на выходе: <span style="color: red;">' + evt.data.substring(13,18) + '</span></li>'+ //'<li>Награзка навыходе: <span style="color: red;">' + evt.data.substring(19,22) + '</span></li>'+ //'<li>Частота напряжения на выходе: <span style="color: red;">' + evt.data.substring(23,27) + '</span></li>'+ //'<li>Напряжение батареи: <span style="color: red;">' + evt.data.substring(28,32) + '</span></li>'+ //'<li>Температура UPS: <span style="color: red;">' + evt.data.substring(32,37) + '</span></li>' ); } function writeToScreen(message) { var pre = document.createElement("p"); $(pre).addClass('del'); pre.style.wordWrap = "break-word"; pre.innerHTML = message; $('.del').remove(); if(edit==1){ } output.val(message); } window.addEventListener("load", init, false) </script>
import serial import sys sys.path.append('../..') import time from SingleSocket.Output import Output SOCKET_PORT = 9999 SOCKET_HOST = '127.0.0.1' stream = Output(host=SOCKET_HOST, port=SOCKET_PORT, web=True) def starts(): port = stream.start() print('Emitting port: {:d}'.format(port)) if not stream.running: exit(0) ser = serial.Serial('COM4', 2400, timeout=0) while ser: try: ser.write(b"Q1\r") ups1= ser.read(100) ser.timeout = 1 #ser.open() print(ups1) stream.append_msg(ups1) #time.sleep(2) except socket.error, msg: stream.stop() ser.close() ser.open() starts() starts()
from imaplib import IMAP4_SSL . . . server.select('INBOX') typ, data = server.search(None, '(UNSEEN)', '(FROM "box@server.com")') for msgId in data[0].split(): subj = server.fetch(msgId, '(BODY.PEEK[HEADER.FIELDS (SUBJECT)])')[1][0][1].strip().decode('utf-8') if subj[9:19] == 'string1' or subj[9:19] == 'string2': . . .
import sys print 'Welcome!' sys.stdout.flush() bytes = sys.stdin.read(16)
if( 1.2 < kf_h < 1.4):
print kf_h
Не работает..
if (kf_h > 1.2) and (kf_h < 1.4):
print kf_h
не работает
if (kf_h > 1.2):
if(kf_h < 1.4):
print kf_h
не работает
if (kf_h > 1.2) or (kf_h < 1.4):
print kf_h
работает...но мне это не надо
C:\Python35-32\Lib\site-packages\PyQt5\qmake.exe -spec win32-msvc2015 -o qtdetail.mk qtdetail.pro
nmake -f qtdetail.mk release
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
“C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe” -f qtdetail.mk.Release
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_CORE_LIB -DNDEBUG -I. -I..\Python35-32\Lib\site-packages\PyQt5\include -IC: /Python35-32/Lib/site-packages/PyQt5/include/QtCore -Irelease -I..\Python35-32\Lib\site-packages\PyQt5\mkspecs\win32-msvc2015 -Forelease\ @C:\Users\Laptop\AppData\Local\Temp\nmCF0E.tmp
cl : Command line warning D9002 : ignoring unknown option ‘-Zc:throwingNew’
qtdetail.cpp
.\qtdetail.cpp(1) : fatal error C1083: Cannot open include file: ‘QCoreApplication’: No such file or directory
NMAKE : fatal error U1077: ‘“C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\cl.EXE”’ : return code ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘“C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe”’ : return code ‘0x2’
Stop.
Error: Failed to determine the detail of your Qt installation. Try again using
the –verbose flag to see more detail about the problem.
for attachment in email['attachments']: # save each attachment in current directory file_name = attachment['filename'] content_type = attachment['content_type'] data = attachment['data'] with open(file_name, 'w') as f: f.write(data)