Parse And Extract Information From HTML Using SQL
This is a question that seems to have been asked here a few times recently. I've just come across this on PHP Classes and thought it might be of interest to anyone trying to do this, I've not used it myself so it is "Sight unseen" Code:
View Complete Forum Thread with Replies
Related Forum Messages:
Using PHP To Parse Html Tables And Extract Values
I've been presented with a task of parsing multiple .jsp's (this is after they have been executed server side so I guess for all purposes its actually a html file). Anyway each of these pages have large complex tables displaying a lot of reporting data for one of our systems. My original method of carrying out this task was to go into the code and get the actual DB querys that the page executes and have this more as a bash based solution. However after spending several days trying to hack my way through a jungle of 100's of querys which dont hold to any naming convention Im going to plan B. So here's what Im looking to do. Get php to construct the correct url for the jsp. What I mean by construct is to make the url while dynamically inserting the correct values into the url as it uses GET to set the date range of the information it writes to the browser. Once its done that and requested the page is processed I want php to search through the page and find the results that Im looking for, assign them to variables and finally format the information from all the different jsp's into one php page. One nice thing is that I'm able to modify the .jsp's to wrap a comment around the data I want for example. I think this should remove the hardest part of the job which is having php identify what values I actually want. #take_this_value# 1234556 ####### What I dont know is how to get PHP to request the url I create,parse it and extract the values. I'm guessing this is a job for wget and regular expressions but Im not too sure where to start (or if there is more appropriate functions to use).
View Replies !
Parse An Html Page With Php To Pull Some Information
Im trying to parse an html page with php to pull some information from it and its not working correctly. I am running this to pull the ul from the page. its the only one on the page with the class directories and it doesnt stop pulling information after the end of the ul. preg_match('/<ul class="directories">(.*)</ul>/', $postResult, $array);
View Replies !
Information Regarding $_Session And Extract
I am new to PHP. I would need some information on the following: 1. a) I wanted to know from where the data is extracted and stroed in the global assocoative arrays ( specifically what will be the contents of $_Session ?) b) Is there any way by which i can get to know all the keys of the arrays ( specifically what are the Keys of $_Session ?) extract($_GET); extract($_POST); extract($_COOKIE); extract($_SERVER); #extract($_SESSION);
View Replies !
Parse/Extract Data
I am using cURL to access a remote search query. I am having no problems getting the data, but parsing it into something more usefull is causing me some trouble. I want to strip out all of the "header data" (everything from <html>.......<table>[GOOD DATA]<more junk>) I am guessing that Regular Expressions are probably the best way to go, but I have the slightest idea of how to begin.
View Replies !
Extract EXIF Information Before Uploading
I am just wondering whether I am able to extract EXIF information from photo before actually uploading it to the server. Because I have to do some validation whether user can actually upload that picture using EXIF info.
View Replies !
Extract The Information By Converting The Binary File To Plain Text
I tried to extract the information by converting the binary file to plain text but I couldn't find any defining characteristics which I could use to extract the information. After looking around to see if anyone else had managed to accomplish this I found that the Freetype library has functions which can access the information I want, specifically TT_Get_Name_ID and TT_Get_Name_String. However I can't figure out how to access these functions from PHP (even though I have freetype installed with GD) or how to convert the code to php.
View Replies !
Parse Information In A PDF
So I've done some googling but haven't been able to find information about reading information in pdf files. I need to extract some information from a pdf file and use that information to rename and move the file to another directory. Anyone ever attempted something like this?
View Replies !
Parse Some Information From A Site
What i am trying to do is parse some information from a site (easy enough) however i need to be loged in to the site to get that information and i have no idea how to do that. Could someone give me an example please? http://sigil.outwar.com login_username=username login_password=password Once loged in i then need to go to another page which can just be linked to once loged in.
View Replies !
Parse Login Information
I am just trying to write few web pages in php to manage certain things with mysql. At the moment I've written everything to check the username and password on the first page. But i've included this bit of code- <meta http-equiv='refresh' content=ƆURL=main.php'> to load the other page if the login is correct. I thought the session variables are kept so I put the username and password in to $_SESSION['username'] and $_SESSION['password'], but these values do not get parsed to main.php.
View Replies !
Parse A Text DB File And Seperate All Information In It
I have a little brain freeze going here. I can't remember how to do this. I'm trying to parse a text DB file and seperate all information in it so that I can insert them into MySQL as seperate values in seperate fields. for example, 1 | howdy | there That would be three peaces with three different fields in MySQL. I know I've done this before but can't for the life of me figure out how I did it. All I need is somebody to jog my memory and get that little brain of mine weorking again.
View Replies !
RemoveHandler .html .htm (parse Php In .html Files)
I want to parse php in .html files. I put this in .htacces file: RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html Its work, but some of my php aplications have urls: www.mysite.com/this-is-page without .html in the end how to parse that? Which code I must use.
View Replies !
Extract Headlines From A HTML File.
I try to write a simple web crawler. It has to do the following: 1) Open an URL and retrieve a HTML file. 2) Extract news headlines from the HTML file 3) Put the headlines into a RSS file. For example, I want to go to this site and extract the headlines: www.unstrung.com/section.asp?section_id=86 The problem is I do not know howto extract a headline from a HTML file. I mean HTML is not structured as XML, so I do not really know to solve this problem. I notice that PHP has URL Functions to deal with HTML file. For example, you have get_meta_tags () to extract meta tag content attributes from a HTML file. But then, extract meta tag is easy. With headlines, I don't really know where the headlines are on a HTML file. Would anyone give me inputs on this? This is not an impossible problem. If you look at Google News (http://news.google.com/), they crawl the web and sort the headlines on their site.
View Replies !
Extract Records From HTML Of Another Site
First of all let me say I'm new to php. I pieced the following code together from samples I found on the net and a book I bought called PHP Cookbook. So please forgive me if this isn't the best approach - I'm open to suggestions I finally got my code to work that logs into another site and pulls the orderstatus page to my server. <?php /* Login to site */ $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieFileName"); curl_setopt($ch, CURLOPT_URL,"https://www.homier.com/default.asp?page=signin"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "EMail=homierorders@swbell.net&Password=1040ez"); ob_start(); // prevent any output curl_exec ($ch); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($ch); unset($ch); /* Dump html of orderstatus page into a file on my server */ $fh = fopen('raw_orderstatus.html','w') or die($php_errormsg); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookieFileName"); curl_setopt($ch, CURLOPT_URL,"https://www.homier.com/default.asp?page=orderstatus"); curl_setopt($ch, CURLOPT_FILE, $fh); curl_exec ($ch); curl_close ($ch); ?> My problem: How can I capture only the data in the "<td class='n8n_CCCCCC_default>" tags? Is there a way to do this at file creation? I checked with my ISP and I can't use LYNX -DUMP file.html The goal here is to load these records into MYSQL database.
View Replies !
PHP4 : Extract Text From HTML File
I would like to extract the text in an HTML file For the moment, I'm trying to get all text between <tdand </td>. I used a regular expression because i don't know the "format between <tdand </td> It can be : <tdtext1 </td> or <td> text1 </td> or anything else eregi("<td(.*)>(.*)(</td>?)",$text,$regtext); The problem is that, if I have <tdtext</td> <td>text2</td> regtext will return text</td><td>text2. How can I change the expression so that it stops at the first occurence of </td>?
View Replies !
Extract Html Table Cells And Put To An Array
i have a table like: <tr><td>headA</td><td>headB</td><td>headC</td><td>headD</td></tr> <tr><td>1a</td><td>1b</td><td>1c</td><td>1d</td></tr> <tr><td>2a</td><td>2b</td><td>2c</td><td>2d</td></tr> <tr><td>3a</td><td>3b</td><td>3c</td><td>3d</td></tr> <tr><td>4a</td><td>4b</td><td>4c</td><td>4d</td></tr> where there can be any number of rows and there can be any number of columns. how can i read through this and create an array for each row, and use the header row as the keys. ie have it something like: QuotemyArray[0] = array( 'headA' = '1a', 'headB' = '1b', 'headC' = '1c', 'headD' = '1c', ); myArray[1] = array( 'headA' = '2a', 'headB' = '2b', 'headC' = '2c', 'headD' = '2c', ); etc....
View Replies !
Regalar Expression To Extract An Html Link From A Page
I have a regalar expression to extract an html link from a page: href=(["']?)([^>1]*.html)1(?: [^>]*)?> It looks after the "href" for an optional quote and then looks for something that is not the quote or the endarrow. The problematic part is [^>1]*. It should exclude anything with the quote, but somehow that doesn't work. Maybe 1 is not allowed inside brackets? I would like some advice on how to handle this.
View Replies !
Using PHP To Parse Through HTML
I'm using PHP 4 and trying to parse through HTML to look for HREF attributes of anchor tags and SRC attributes of IMG tags. Does anyone know of any libraries/freeware to help parse through HTML to find these things. Right now, I'm doing a lot of "strstr" calls, but there is probably a better way to do what I need.
View Replies !
Html To Parse Php
i want my html files to parse php files. how do i do it? i have access to httpd.conf what should i add? is it not advised to do something like that?
View Replies !
Parse Php Through Html...
I'm trying to get my php pages to parse php within HTML, instead of php brackets. Basically instead of having: lets echo a variable/constant: <?php echo $somevariable . ' or ' . SOMECONSTANT; ?> I want to use somhing like: lets echo a variable/constant: {$somevariable} or {SOMECONSTANT}Is this at all possible? I'm not wanting to do anything more difficult than echoing simple variables or constants..
View Replies !
Parse Html
I want to chunk a html page and parse that page using php.ie that html page contain many data.I want to retrive that data using php and want to save in a database.
View Replies !
Parse PHP Code In .html??
I was wondering if it's possible to parse PHP code in .html documents without requiring root access (since I'm on a virtual server). I want to make a two line call to a log program, but I don't want to have to change all of my .html files to .php.
View Replies !
Parse A Html Site
does anybody know a script that cachtes any data from a web site (html) and put it in a csv or something? I think parse is here the magic word or?
View Replies !
Parse A Html Document
Anyone have any ideas how to parse a html document. I am trying to extract out specific information from the page. Also, what do you do if the page is dynamic (e.g. a cgi generated page) how do you find it?
View Replies !
Parse Html Page
How can I import a html page with my php script? I have a simple html page that actually just generates a simple table of values. I just want to strip the values to insert in to a database. How do I import the html page to my php script to parse it?
View Replies !
Parse HTML From Within A PHP Script
I'm writing my website backend. This consists of a series of pages for adding and updating information about widgets to a database. Most of the pages have bene very simple, however I elected that three fields would accept HTML as there data by necessity. These three fields contain a manufactures description of the item, a description written specifically by the company, and lastly the spec sheet on the product. I'm designing the back end page that will allow modification of existing database items. I'm using <textarea> tags for the data. The problem being that I believe if I write a line like: echo "<textarea name="$fieldname[$i]" rows="5" cols="25">$thevalue[$i]</textarea> $theValue will be interpreted as the HTML it is instead of displaying the HTML so it can be edited and resaved to the DB. I haven't finished all the entire script so I haven't been able to test that theory yet, so if I'm wrong I'd be happy to hear it. if I'm right how can I get around it?
View Replies !
Parse HTML ASCII
When parsing HTML is it possible to have all the ASCII codes converted to their real values first so that I do not need to search for them to exclude them. For example the following is retrieved as a price however it would be easier to extract using a regex if the code was first converted to a dollar sign: <h3> $249,000 </h3>
View Replies !
How To Parse This Into HTML Tables
I'm trying to parse a file in order to get it displayed onto a webpage using HTML and tables. I got a good deal of the parsing done but there's a problems that I can't solve. So here is a part of the file Code:
View Replies !
How Do I Parse PHP Code Within An HTML File?
I'm trying to figure out a way to save message bodies of the various e-mails I send from my site into HTML pages and then import them when I send the e-mails. But I've never tried anything like this before so I'd appreciate some help. Here's an example of the code I'm using: Code: $email_body = file_get_contents("emails/application_approved.htm"); I can import the HTML files without problems, but I've also got PHP variables in the HTML code and I need to know how to parse those variables. Is it even possible?
View Replies !
WinXP/IIS Set Up For PHP To Parse .html Extensions
I just installed PHP (4.3.3) on a WinXP (SP1) system using IIS (5.1) as the web server. I am using FrontPage 2002 and would like to be able to debug my PHP scripts locally. Since FP does not handle the .php extension as a web page (edit, display, navigation, etc.), I am trying to set it up to parse files with the .html extension. I have added the .php and .html extensions to the Application Configuration page of IIS and I have also applied some regedit changes suggested by the documentation. All to no avail. The .php extension works, the .html does not.
View Replies !
How To Use .htaccess To Parse Only .html Files As .php?
I am trying to make my server (Apache) parse .html files as .php. I found this line of code: ForceType application/x-httpd-php placed it in an .htaccess file and uploaded it to the directory I wanted it to work. And it worked; my .html files are all parsed as .php. But, apparently, so are my images, so they aren't loaded into the pages. And something else, my css file isn't found anymore by Netscape and Mozilla, while IE has no problem... I'm calling my css file with @import url(all.css); in the <style> block in the head of my .html files. How do I make the server parse _only_ .html files as .php, and why don't Mozilla and Netscape find the css file? (They did before I sent the .htaccess file)
View Replies !
Parse .html As Stopped Working
I recently upgraded an old 4.2.2 PHP to 4.3.11 One change I made after was to get my .html files to parse thru PHP. Yes, I've read for years not to do this, but I do anyway. I accomplish this by changing: AddType application/x-httpd-php .php to AddType application/x-httpd-php .php .html But now, all my apache redirects don't work, and the apache error pages want to download. The .html parse thru PHP, and ofcourse .php is fine. I've covered everything I know, and would like to know if anyone else has come across before.
View Replies !
Parse Error On The Last Line Of Code </html>
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start (); require_once('connect.php'); if ($_SESSION['username']){ //test for logged-in $query = "SELECT status FROM accounts WHERE username='".$_SESSION['username']."'"; $result = mysql_query ($query) or die("<b>A fatal MySQL error occured</b>. <br> Error: (" . mysql_errno() . ") " . mysql_error()); $row = mysql_fetch_array ($result,MYSQL_NUM); if ($row[0] == 0){ $error_message .= "<P>Your account has been frozen. Email the <A HREF='mailto:account_status@severedrealm.net'>webmaster</A> for more information.</P>";} if ($row[0] == 1){ $query2 = "SELECT name, hp, gold, exp FROM characters WHERE username='".$_SESSION['username']."'"; $result2 = mysql_query ($query2) or die("<b>A fatal MySQL error occured</b>. <br> Error: (" . mysql_errno() . ") " . mysql_error()); $character_table .= "<TABLE CELLSPACING=ƈ' CELLPADDING=ƈ' BORDER=Ɔ'><TR><TD>Name</TD><TD>Hit Points</TD><TD>Gold</TD><TD>Experience</TD><TD>Delete</TD></TR>"; $x=0; while ($character = mysql_fetch_array ($result2)) { $x=$x+1; $character_table .= "<TR><TD>".$character[1]."</TD><TD>".$character[2]."</TD><TD>".$character[3]."</TD><TD>".$character[4]."</TD>"; $character_table .= "<TD><form action='character.php' method='post'><input type='hidden' name='character' value='".$character[1]."'><INPUT TYPE='submit' NAME='delete_character_submit' VALUE='delete_character'></FORM></TD></TR>";} $character_table .= "</TABLE>"; if ($x >= 1){ $error_message .= "<P>You have too many characters. You must delete ".$x."before you can create another.</P>"; }else{ $character_creation_form .= "<FORM ACTION='character.php?op=create_character' METHOD='post'>"; $character_creation_form .= "<table cellspacing=ƈ' cellpadding=ƈ' border=Ɔ'><tr>"; $character_creation_form .= "<td>New Character Name:</td><td><input type='text' name='new_character_name' size=ཚ' maxlength=ཚ' value=''/></td></tr>"; $character_creation_form .= "<tr><td></td><td><input type='submit' name='New_Character_Submit' value='Create Character'></td></tr></table></FORM>";} if ($row[0] == 2){ $query3 = "SELECT name, hp, gold, exp FROM characters WHERE username='".$_SESSION['username']."'"; $result3 = mysql_query ($query3) or die("<b>A fatal MySQL error occured</b>. <br> Error: (" . mysql_errno() . ") " . mysql_error()); $character_table .= "<TABLE CELLSPACING=ƈ' CELLPADDING=ƈ' BORDER=Ɔ'><TR><TD>Name</TD><TD>Hit Points</TD><TD>Gold</TD><TD>Experience</TD><TD>Delete</TD></TR>"; $x=0; while ($character = mysql_fetch_array ($result2)) { $x=$x+1; $character_table .= "<TR><TD>".$character[1]."</TD><TD>".$character[2]."</TD><TD>".$character[3]."</TD><TD>".$character[4]."</TD>"; $character_table .= "<TD><form action='character.php' method='post'><input type='hidden' name='character' value='".$character[1]."'><INPUT TYPE='submit' NAME='delete_character_submit' VALUE='delete_character'></FORM></TD></TR>";} $character_table .= "</TABLE>"; if ($x >= 2){ $error_message .= "<P>You have too many characters. You must delete ".$x."before you can create another.</P>"; }else {
View Replies !
Parse Text From HTML Website, Dump Into DB
I am working on a script to extract statistics (which is updated daily) from a website, and insert them into a MySQL database. I want to take this website: http://www.usatoday.com/sports/bask...players0304.htm and strip off all the HTML tags and etc, make it look like http://www.enlhoops.com/ratings/parsed.txt and then insert each players stat line into the database. I have begun writing the script, getting the file, striping html tags off, but that doesn't seem to work too well.
View Replies !
Parse HTML Table Rows Into Array
I have a script that extracts an HTML table from a page into a text string. I would like to parse each row of the table into an array named "$rows". I would like to keep the html intact so that I could re-create the same table like: Code:
View Replies !
Parse String For Urls, But Not Html Links
I've got this function to convert any urls into the proper links for my CMS. However, if I want to put in my own link <a href="http://www.domain.com">A link to domain.com</a> (rather than the basic url www.domain.com), this function really stuff's it up. Code:
View Replies !
Parse Returned Html Shipping Rate Value
How can I extract as a var, the shipping rate value returned from the HonKongPost website's html webpage/result. I need to extract whichever value is displayed after the $: <input type="hidden" name="total_rate" value="$540"> Code:
View Replies !
Problem Using Htacess File To Parse HTML
I know that there are numerous posts on using an htaccess file to cause a server to parse HTML files for PHP. I've read them all (or at least most), but have not found any help for my problem. Does anyone know of a situation where modifying the htaccess file (or adding one to a specific directory within a hosting account) would cause the following behavior? I added an htaccess file consiting only of the line to a directroy where I would like .html files to be parsed for PHP: Code:
View Replies !
"Cannot Modify Header Information" With Large HTML FORM Options
I'm having some really odd behavior with a PHP script. I have it populating an HTML select form with a for loop. When I try the years 2006 to 1900. I get the following error: PHP Warning: Cannot modify header information - headers already sent by (output started at /Users/chrobb/Sites/city-directory/controlBar.php:54) in /Users/chrobb/Sites/city-directory/controlBar.php on line 88 I've done a fair amount of searching and it looks like this usually shows up when people have some extra whitespace after their closing PHP tags. Doesn't apply seem to apply here. When I crank the number down on the for loop to 94 iterations, the error goes away. Once I crank it up to 95, the error comes into play. So, it's tied to the output somehow. Looking at the raw HTML, there doesn't appear to be any significant difference between the version with 94 iterations versus the one with 95 iterations, except for the error and the failure of my script.
View Replies !
Can A Field Communicate To A Server And Return Information To Another Field Without Retrieving The Whole Html Code Again?
I´ve got a sql table which has 3 fields. Their relation to each other is like this example. | CARS | YEAR | PRICE | ford 2000 ford 2001 ford 2003 volkswagen 1999 volkswagen 2000 I am developing an ASP web page that modifies a specific registry. So, it loads the information to some fields, but the user will be able to change only the "PRICE" field. I have to create two selects, one for "CARS" and other for "YEAR". But the "YEAR" field will only contain the correspondent years for each car the user selects. Example: selecting "ford" in the "CARS" <select> box, only the years "2000", "2001", "2003" would be automatically loaded in the "YEAR" <selec> box. How could i implement it?
View Replies !
Using Includes: Html Form Parse Data Inside 2nd Form.
i'm coming down the stretch, so to speak. i've got a lot of the separate things settled that i need for my main "date entry" form. due to the several data items which need to be collected by this form, i've decided to try using includes, which i've found isn't that tricky at all really. however, one of my includes needs itself to parse it's own little form data to result in the final entry to be submitted in the "date entry" form. perhaps doing this particular bit as an "include" is NOT the best option? Code:
View Replies !
|