Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mg_belohorizonte #33

Closed
wants to merge 4 commits into from
Closed

Conversation

juniorcarvalho
Copy link

spider para Belo Horizonte-MG
Data inicial = 07/05/2016

@@ -7,4 +7,4 @@
'gazette.pipelines.PdfParsingPipeline': 2,
'gazette.pipelines.PostgreSQLPipeline': 3,
}
FILES_STORE = '/mnt/data/'
FILES_STORE = '/home/junior/projetos/scrapy/diario-oficial/data'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aqui tu tinha que manter o /mnt/data/. 😅


def parse_pagelink(self,response):
url = response.xpath('//p[contains(@class,"dom-chamadas")]/a/@href').extract_first()
if url is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Você pode usar também if url: (menos código é mais :)).

items.append(
Gazette(
date=self.start_date,
file_urls=[self.mg_belohorizonte_url + file_url],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descobri há pouco tempo que o Scrapy tem um método pra concatenar URL (o urljoin). Seria algo tipo response.urljoin(file_url).

@juniorcarvalho
Copy link
Author

Blz, nos próximos ficarei atento.

@juniorcarvalho
Copy link
Author

Comecei a fazer mg_uberlandia. Estou apanhando para conseguir pegar a data do diário.
E parece que se prepararam para dificultar a raspagem. Tenho 3 variações de links.
O link do href consigo pegar, agora a data está difícil. Se alguém tiver uma ideia só falar.
Postei a dúvida em :
https://pt.stackoverflow.com/questions/296567/scrapy-xpath-href-ou-span-dentro-da-div

@anapaulagomes
Copy link
Collaborator

@juniorcarvalho eu tentei dar uma olhada na página mas parece que nesse momento site tá fora do ar. Seria bacana você abrir os spiders pra cada cidade em PRs diferentes, assim um não impede o outro de ser mergeado e também ajuda os mantenedores a ter uma boa visão do que cada PR tem.

Amanhã vou tentar novamente - se você tiver notícias que o site voltou ou tiver uma página HTML de exemplo, é só falar.


def parse_ano(self, response):
url_meses = response.xpath('//a[contains(@target,"_blank") and contains(@href,"http://www.uberlandia.mg.gov.br")]')
for url in url_meses:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dado que o código do repositório está em inglês, seria bacana manter esse padrão, mantendo todo o código em inglês também.

Copy link
Author

@juniorcarvalho juniorcarvalho May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vacilei neste PR. Como corrigir este duplo PR ?
A pagina do diário de uberlandia: http://www.uberlandia.mg.gov.br/?pagina=Conteudo&id=39

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não tem problema, acontece! :) Você pode criar uma nova branch (tipo mg-uberlandia) a partir da master, passar as alterações de Uberlândia pra lá e nessa branch aqui você pode:

  1. criar um commit deletando o código de Uberlândia
  2. fazer um rebase interativo para remover/dar squash no commit - isso faria com que o histórico ficasse limpo, sem o último commit de Uberlândia e o commit da deleção. Acho que esse passo aqui é opcional também.

Ainda não consigo carregar essa página. :(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deu timeout aqui. Tu tá conseguindo acessar normal?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sim..normal

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juniorcarvalho parece que não consigo acessar pq tô fora do BR (e não tenho VPN). 🙄 Rola me mandar a página inicial do diário (http://www.uberlandia.mg.gov.br) e essa página que tu mencionou? apgomes88 at gmail dot com

@cuducos
Copy link
Contributor

cuducos commented May 8, 2018

@juniorcarvalho parece que não consigo acessar pq tô fora do BR (e não tenho VPN). 🙄

Que péssimo isso, @anapaulagomes@anaschwendler e @cabral, vocês podem confirmar se isso é mesmo algo relacionado ao país do IP?

De qualquer forma eu já perguntei (informalmente) no Twitter da prefeitura. Veremos.


UPDATE a força do hábito me fez escrever em inglês sem perceber. Reescrevendo em pt-BR!

@anapaulagomes
Copy link
Collaborator

De boas! Obrigada aí pela força. @anaschwendler me deu essa força e confirmou que o problema é esse mesmo.
Boa iniciativa com a prefeitura! Eu já tava pensando em pingar eles. 😅 Absurdo demais essa restrição...

@cuducos
Copy link
Contributor

cuducos commented Jul 10, 2018

Closed in favor of #95

@cuducos cuducos closed this Jul 10, 2018
@jvanz jvanz linked an issue Jun 20, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Belo Horizonte spider
3 participants