Reply
Selecting a section of a string
Old 04-08-2008, 11:31 AM Selecting a section of a string
Average Talker

Posts: 15
Good afternoon all.

I have an application that has a web interface that I need to scrape. I have a basic scrape working OK but I'm struggling to get the sections of code I want on their own.

This is the code I need to scrape from (applogies for the very badly formatted HTML but it is nothing I can change.)
HTML Code:
<html>

<head>

</head>

<body>

<b>Active Jobs</b>
<table>
	<tr>
		<th align="right">Priority</th>
		<th align="left">Job Name</th>
		<th align="left">Owner</th>
		<th align="left">Progress</th>
		<tr><td align="right">1 <td align="left">This is my Job Name <th align="left">Tom <th align="left">63%
	
	</tr>
</table>

<br><br><br>

<b>Inactive Jobs</b>
<table>
	<tr>
		<th align="right">Priority</th>
		<th align="left">Job Name</th>
		<th align="left">Owner</th>
		<th align="left">Progress</th>
		<tr><td align="right">1 <td align="left">This is my Job Name2 <th align="left">Tom <th align="left">100% <tr><td align="right">1 <td align="left">This is my Job Name3 <th align="left">Tom <th align="left">100% <tr><td align="right">1 <td align="left">This is my Job Name4 <th align="left">Tom <th align="left">100%
	
	</tr>
</table>

</body>

</html>
I would love to be able to get the bits of code below into separate strings in PHP. I was going to use preg_match() but thought there is possibly a simpler way...

HTML Code:
<tr><td align="right">1 <td align="left">This is my Job Name <th align="left">Tom <th align="left">63%
	
	</tr>
HTML Code:
<tr><td align="right">1 <td align="left">This is my Job Name2 <th align="left">Tom <th align="left">100% <tr><td align="right">1 <td align="left">This is my Job Name3 <th align="left">Tom <th align="left">100% <tr><td align="right">1 <td align="left">This is my Job Name4 <th align="left">Tom <th align="left">100%
	
	</tr>
Thanks in advance.


Tom
randomness is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-08-2008, 11:41 AM Re: Selecting a section of a string
rogem002's Avatar
Webmaster Talker

Posts: 609
Name: Mike
Location: United Kingdom
An explode could work, but preg_match would be the best way.
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 04-09-2008, 01:55 AM Re: Selecting a section of a string
Ultra Talker

Posts: 307
Use php dom extension to load html, it can load badly formed html as well.
__________________
tiny url
dman_2007 is offline
Reply With Quote
View Public Profile Visit dman_2007's homepage!
 
Reply     « Reply to Selecting a section of a string
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12361 seconds with 12 queries