Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

410
Visualizações
python mechanize submit response.read() doesn't return correct page?

all! I am trying to do some data processing on a publicly accessible database (property tax records, I know, not very glamorous!). The code runs perfectly, but it doesn't return the right page. When I enter the information into the forms manually, and click "submit" I get a lovely page full of relevant data. But when I submit the form via python mechanize, I do not get the same page. For example:

brwsr = mechanize.Browser()
brwsr.open("https://sdat.dat.maryland.gov/RealProperty/Pages/default.aspx")
brwsr.select_form(nr = 0)
# <option selected="selected" value="02">ANNE ARUNDEL COUNTY</option>
brwsr.form["ctl00$cphMainContentArea$ucSearchType$wzrdRealPropertySearch$ucSearchType$ddlCounty"] = ['02'] 
# STREET ADDRESS
# <option selected="selected" value="01">STREET ADDRESS</option>
brwsr.form["ctl00$cphMainContentArea$ucSearchType$wzrdRealPropertySearch$ucSearchType$ddlSearchType"] = ['01']
brwsr.submit()
# this works wonderfully!

# this is now the second page
brwsr.select_form(nr = 0)
# street number
brwsr.form["ctl00$cphMainContentArea$ucSearchType$wzrdRealPropertySearch$ucEnterData$txtStreenNumber"] = '523' # just an example
# street name
brwsr.form["ctl00$cphMainContentArea$ucSearchType$wzrdRealPropertySearch$ucEnterData$txtStreetName"] = 'SIXTH' # just an example
response = brwsr.submit()
print(response.read())

This returns no errors at all, but some of the html returned is the following:

<img src="/RealProperty/egov/img/ajax-loader.gif" id="imgLoader" alt="Loading... Please Wait." title="Loading... Please Wait." />\r\n 

Hmmmmmmm... "Loading"? "Please wait"? The second page seems to be dynamically generated, i.e., maybe it is running scripts that haven't finished by the time the response come. I've been reading and poking, and people seem to say that mechanize is the wrong tool for this kind of job. But what is the right tool? I feel like it ought to be straight-forward to parse the data on that second page... if I can just get my hands on it!

Thank you for your time!

Best, Susan

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda