473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get info from a page

Hi everyone,
The fragment below is from a table on a page I pull, (scrape), information
from. The fragment is one row of what is potentially several rows.

The items with id's I can get:
id="dgdBusSchedule__ctl1_lblDepartureDate" yields "06:11"
id="dgdBusSchedule__ctl1_lnkRouteNumber" yields "6"

The id's above change with each row - ... _ctl2_..., ... _ctl3_..., easy to
loop through.

The id's above is the major data items for my app. The last cell in the row
I cannot seem to get. It is the text which reads "University". It is the
destination of route 6. This item seems to have no discerning id, name or
tag, even the class is generic on this page.

What methods are used to iterate over a table and all of its rows/cells?

All opinions appreciated!

<td scope="row" class="gAltContentSection">
<span
id="dgdBusSchedule__ctl1_lblDepartureDate">06:11</span></td>
<td scope="row" class="gAltContentSection">
<a id="dgdBusSchedule__ctl1_lnkRouteNumber"
href="javascript:document.forms[&quot;frmBusStopScheduleResults&quot;][&quot;txtRouteId&quot;].value
=&quot;30&quot;;document.forms[&quot;frmBusStopScheduleResults&quot;][&quot;txtRouteDepartureTime&quot;].value
=&quot;371&quot;;gfnTransit_SwitchPostBackUrl(&quo t;BusStopSchedule_Results.aspx|BusStopDetail.aspx& quot;,&quot;RouteSchedule_Results.aspx&quot;,&quot ;frmBusStopScheduleResults&quot;,&quot;_blank&quot ;,&quot;NOVIEWSTATE&quot;);RouteSchedulePostBack(& quot;&quot;,&quot;&quot;,&quot;frmBusStopScheduleR esults&quot;,&quot;txtRouteNumber&quot;,&quot;6&qu ot;);">6</a></td>
<td scope="row" class="gAltContentSection">University</td>

Jun 27 '08 #1
4 942
James wrote:
What methods are used to iterate over a table and all of its rows/cells?
If you would want to loop over the table, you would have to parse the
html code into some kind of object tree. I would suggest that you just
use a regular expression to get the data from the code.

Something like:

Matches m = Regex.Matches(page,
"<span[^>]+?id=""[^""]+?lblDepartureDate""[^>]*?>([^<]+?)</span>.*?<a[^>]+?id=""[^""]+?lnkRouteNumber""[^>]*?>(\d+)</a>")
--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #2
Thanks Göran,

Regex seems quite powerful. Looking on msdn I have found info on the methods
for regex, but lack the knowledge how to code one. Where is a page to teach
me how to make regex? Once I learn the syntax, agree, get the info I need is
possible.

Thanks Göran!

"Göran Andersson" <gu***@guffa.comwrote in message
news:es**************@TK2MSFTNGP04.phx.gbl...
James wrote:
>What methods are used to iterate over a table and all of its rows/cells?

If you would want to loop over the table, you would have to parse the html
code into some kind of object tree. I would suggest that you just use a
regular expression to get the data from the code.

Something like:

Matches m = Regex.Matches(page,
"<span[^>]+?id=""[^""]+?lblDepartureDate""[^>]*?>([^<]+?)</span>.*?<a[^>]+?id=""[^""]+?lnkRouteNumber""[^>]*?>(\d+)</a>")
--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #3
Found a page! http://www.regular-expressions.info/reference.html

"Göran Andersson" <gu***@guffa.comwrote in message
news:es**************@TK2MSFTNGP04.phx.gbl...
James wrote:
>What methods are used to iterate over a table and all of its rows/cells?

If you would want to loop over the table, you would have to parse the html
code into some kind of object tree. I would suggest that you just use a
regular expression to get the data from the code.

Something like:

Matches m = Regex.Matches(page,
"<span[^>]+?id=""[^""]+?lblDepartureDate""[^>]*?>([^<]+?)</span>.*?<a[^>]+?id=""[^""]+?lnkRouteNumber""[^>]*?>(\d+)</a>")
--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #4
On Jun 8, 8:35*am, "James" <james_dev...@hotmail.comiwrote:
Found a page!http://www.regular-expressions.info/reference.html

"Göran Andersson" <gu...@guffa.comwrote in message

news:es**************@TK2MSFTNGP04.phx.gbl...
James wrote:
What methods are used to iterate over a table and all of its rows/cells?
If you would want to loop over the table, you would have to parse the html
code into some kind of object tree. I would suggest that you just use a
regular expression to get the data from the code.
Something like:
Matches m = Regex.Matches(page,
"<span[^>]+?id=""[^""]+?lblDepartureDate""[^>]*?>([^<]+?)</span>.*?<a[^>]+?*id=""[^""]+?lnkRouteNumber""[^>]*?>(\d+)</a>")
--
Göran Andersson
_____
http://www.guffa.com- Hide quoted text -

- Show quoted text -
you can also use javascript to iterate in rows and cells...
<script>
function delete_all(table_element)
{
for(i=table_element.rows.length-1; i -1; i--)
{
... check row content ...
}
}
</script>
... more at http://www.siccolo.com/articles.asp
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Lorenzo Thurman | last post by:
I'm moving from Cold Fusion to PHP and I have a question that none of the books I have answers adequately: In Cold Fusion, database connection parameters like the table, username and password are...
2
by: | last post by:
Hey All, I'm using response.write to create a dymantic webpage. Basically just write the HTML out with response.write. The problem I am having is that when I do this it puts the Meta tag info...
1
by: Chris | last post by:
Hi, how can I send information that is in the Response.OutputStream to the client but continue server processing without having to close the page , or without having to Reponse.End() the...
4
by: Alan Silver | last post by:
Hello, I'm doing a cross page post, and want to pick up information from the previous page. The problem is that the previous page contains a user control that is loaded into a Placeholder at run...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
6
by: matt | last post by:
hello, i am having trouble doing something. when a user triggers a certain event in my app, i need to initiate another web request to one of my other webpages, programmatically. currently, i do...
20
by: Tim Reynolds | last post by:
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am...
11
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't...
1
renegades
by: renegades | last post by:
A big hello to everyone. OK, I have a simple XML flash that shows 4 slides the slides and their link are determined in an XML like; <track> <title>Take a quick survey</title> <creator>my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.