Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default help with web query

Hi,
Iīm trying to run a query to import some data from the web.
The problem is that the url from the page doesnt work with the query.
The data is displayed in the web as a table , generated by hitting an
"OK" button. The problem is that the url from the generated table(page)
seems to be some generic address. You canīt load the table just by
writing the url on the IE. You have to go to a page, hit the "OK"
button and then youīre taken to the table. Can anyone help me?
the pages are these :

http://www.sidra.ibge.gov.br/bda/ta...t&o=5&i=P&c=655

and after pressing the ok you get to that one, wich is the one
containing the data Iīm looking for :

http://www.sidra.ibge.gov.br/bda/ta...asp?z=t&o=5&i=P

if you use this last address directly as an url an error message shows
up.


thanks very much.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default help with web query

The URL's in your post do NOT work. Please provide working URL's and
I'll try to help you. I'm expert user of web queries so I should be
able to help you but I need to see the data first.

-Ken

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default help with web query

Iīm sorry!!
thanks for trying t help me.
this is the correct url for the first url. you have to click the "OK"
button in the bottom of the page to be redirected to the next url.


http://www.sidra.ibge.gov.br/bda/tabela/listabl.asp?
z=t&o=1&i=P&c=655

http://www.sidra.ibge.gov.br/bda/tab...sp?z=t&o=1&i=P

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default help with web query

Unfortunately, the output table is not showing up in Excel. I've tried
several things but couldn't get it to show up. The first URL is passed
to server which creates the HTML for the table, but it uses the input
parameter string plus your selections on the first page to generate the
second page.

Thus,

First URL Parameters + First URL Selection Inputs = Second Page

It's not enough to just use the 2nd URL to generate the table. You
need the inputs from the first page which are not being passed into the
2nd URL. Rather, your selection inputs are passed to the server and
the HTML rendering is automatically generated.

Sorry.

-Ken

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default help with web query

thanks anyway!

I tried to find something on the first url's HTML code that would help
me building a code to acces directly the data on the second url, but I
couldnīt come up with anything usefull...]

thanks again,
Ian



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default help with web query

Hi Ian,

The following routine will get the data you need, but you will have to parse
it out programmatically. In order to get it to work, you must set a
reference to Microsoft XML 5.0 via Tools | References in the VBE. If you
don't have 5.0, use the highest you have and change the first line of code
to the correct version number.

Sub test()
Dim xml As XMLHTTP50
Dim sPost As String
Dim abytPostData() As Byte
Dim sResponse As String

sPost = "i=P&"
sPost = sPost & "gv=n&"
sPost = sPost & "tab=655&"
sPost = sPost & "nivt=0&"
sPost = sPost & "unit=0&"
sPost = sPost & "pov=1&"
sPost = sPost & "orv=2&"
sPost = sPost & "opv=1&"
sPost = sPost & "sev=63&"
sPost = sPost & "opc315=1&"
sPost = sPost & "poc315=1&"
sPost = sPost & "orc315=3&"
sPost = sPost & "sec315=7169&"
sPost = sPost & "ascendente=&"
sPost = sPost & "opp=1&"
sPost = sPost & "pop=1&"
sPost = sPost & "orp=4&"
sPost = sPost & "sep=28953&"
sPost = sPost & "nome=&"
sPost = sPost & "pon=1&"
sPost = sPost & "orn=1&"
sPost = sPost & "qtu1=1&"
sPost = sPost & "opn1=2&"
sPost = sPost & "qtu6=2&"
sPost = sPost & "opn6=0&"
sPost = sPost & "opn7=0&"
sPost = sPost & "qtu7=9&"
sPost = sPost & "proc=1&"
sPost = sPost & "notarodape=&"
sPost = sPost & "arquivo=&"
sPost = sPost & "formato=1&"
sPost = sPost & "modalidade=1&"
sPost = sPost & "email=&"
sPost = sPost & "decm=99&"
sPost = sPost & "cabec=&"
sPost = sPost & "gera= OK "

abytPostData = StrConv(sPost, vbFromUnicode)
Set xml = New XMLHTTP50
With xml
.Open "POST", _
"http://www.sidra.ibge.gov.br/bda/tabela/protabl.asp?z=t&o=1&i=P"
.setRequestHeader "Content-Type", _
"application/x-www-form-urlencoded"
.send abytPostData
sResponse = .responseText
End With

Set xml = Nothing
Debug.Print sResponse
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


icaos wrote:
thanks anyway!

I tried to find something on the first url's HTML code that would help
me building a code to acces directly the data on the second url, but I
couldnīt come up with anything usefull...]

thanks again,
Ian


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default help with web query

jake,
you are incredible!!
Thanks a lot!!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert hard coded query criteria to Parameter Query Melanie[_2_] Excel Discussion (Misc queries) 0 July 15th 08 09:59 PM
Excel 2007 / MS Query - editing existing query to another sheet Hotpepperz Excel Discussion (Misc queries) 0 June 13th 08 06:53 PM
Save data retreived from query without saving query Anthony Excel Discussion (Misc queries) 0 January 25th 06 07:17 PM
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? jocke Excel Discussion (Misc queries) 1 November 29th 05 01:44 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM


All times are GMT +1. The time now is 06:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright Đ2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"