zester.

Bibliotecas de clientes mais fáceis de python
Baixe Agora

zester. Classificação e resumo

Propaganda

  • Rating:
  • Licença:
  • MIT/X Consortium Lic...
  • Preço:
  • FREE
  • Nome do editor:
  • Steve Pulec
  • Site do editor:
  • http://github.com/spulec/

zester. Tag


zester. Descrição

Zester é uma biblioteca Python que facilita a desenvolver clientes Python para sites sem APIs.No LXML, no XPath, apenas JavaScript.let faz uma biblioteca de clientes para o Hacker News, salvando o seguinte código em um arquivo chamado HnClient.py: do Zester Importe MultipleClient, attributeClass HNClient (multipleglient): URL = "http://news.ycombinator.com/" Title = atributo (selector = "$ ('. Título A')", modificador = "$ (EL) .HTML (EL). ) ") Link = atributo (selector =" $ ('. Título A'), modificador = "$ (EL) .attr ('href')") aponta = atributo (selector = "$. ') ", modificador =" $ (EL) .html (). Substitua (' pontos ',' ') ") Agora, vamos usar o cliente que acabamos de fazer. Abra um shell python: >>> do HNClient Import HnClient >>> Cliente = hnclient () >>> histórias = Client.Process () >>> histórias HnClientResponse (pontos = u'200 ', link = u' http://daltoncaldwell.com/what-twitter-could-have-been ', title = u'what poderia ter sido') >>>>>>.titlewhat twitter poderia ter sido >>> Histórias de impressão .linkhttp: //daltoncaldwell.com/what-twitter-could-Have-been >>> Histórias de impressão .Points56we subclassed multipleglient lá porque estávamos planejando retornar vários resultados. Se queríamos fazer um cliente para algo parecido com Weather.gov que retornou um único resultado, poderíamos fazer algo assim: De Zester Import SingleClient, attributeClass weatherclient (singleClient): URL = "http://forecast.weather.gov/ MAPCLICK.PHP? LAT = {LAT} LON = {LNG} "Temperatura = atributo (seletor =" $ ('. Myforecast-atent-lrg'). HTML () ") Humidade = atributo (seletor =" $ ('. Condições de corrente-detalhe Li '). Conteúdo () ") Heat_Index = atributo (selector =" $ ('. Condições de corrente-detalhe-detalhe Li '). Conteúdo () ") Def __init __ (auto, lat, lng, * args, ** kwargs): super (weatherclient, auto) .__ init __ (* args, ** kwargs) self.url = self.url.format (lat = lat, lng = lng) isso também demonstra como Você pode permitir que os argumentos sejam tirados: >>> do weather_client Import WeatherClient >>> Cliente = clipeclient (lat = 40.7143528, lng = -74.0059731) >>> curr_weather = client.Process () >>> curr_weatherweatherresponse (heat_index = u ' 82 \ xb0f (28 \ xb0c) ', temperatura = u'80 \ xb0f', umidade = u'58% ') >>> Print curr_weather.temperature80 ° F >>> Improduzir curr_weather.humidez58% >>> Improduzir curr_weather.heat_index82 ° F (28 ° C) Installação dependente do Ghost.py. Você deve instalá-lo antes de instalar Zester. Ghost.py também exigirá a instalação de PyQT ou Pyside.After Ghost.py está instalado, para instalar Zester: Pip Install Homepage de Zesterproduto


zester. Software Relacionado