Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-25-2012, 06:17 PM   PM User | #1
Scharfheimlich
New Coder

 
Join Date: Jun 2011
Posts: 15
Thanks: 5
Thanked 0 Times in 0 Posts
Scharfheimlich is an unknown quantity at this point
Exclamation Read URLs from csv

Hello,

I would like to ask you for this issue: I have made this php:

PHP Code:
<?php
//include parseru
include('simple_html_dom.php');

//read parsovany stranky
$html file_get_html('http://www.webpage1.com/123456');

//find Weight
$DC1 $html->find('tr[id=product-details-weight]'0)->plaintext;
//split(tady to bude podle dvojtecky)
$w explode(':'$DC1);
$BM1 trim($w[1]);

//find Shape
$DC2 $html->find('tr[id=product-details-shape]'0)->plaintext;
//split(tady to bude podle dvojtecky)
$w explode(':'$DC2);
$BM2 trim($w[1]);

//find Color
$DC3 $html->find('tr[id=product-details-color]'0)->plaintext;
//split(tady to bude podle dvojtecky)
$w explode(':'$DC3);
$BM3 trim($w[1]);

etc etc

//echo:
echo ''.$BM1.','.$BM2.','.$BM3.',etc,etc'';

//create file
$myFile = "RESULTS.csv";
$fh = fopen($myFile, '
w') or die("can't open file");

//header
$stringData = "
Weight,Shape,Color,etc,etc";
//write
fwrite($fh, $stringData);

//Insert data to .csv
$stringData = "
$BM1,$BM2,$BM3,etc,etc";
fwrite($fh, $stringData);


?>
This .php reads example URL (http://www.webpage1.com/123456) and create RESULTS.csv with data on it (2 rows). I would like to improve it that it would read URLs from specific .csv, so it would write everything i need in RESULTS.csv.

For example: in file URLS.csv is 50 different webpages, so in file RESULTS.csv will be 50 rows with data + 1 row as a header. If file URLS.csv will be changed to 65 urls, as a result will be file with 66 rows... etc...

I hope you are understanding me... (i am sorry for my bad english)

With kind regards.... S.

Last edited by Scharfheimlich; 08-25-2012 at 08:57 PM..
Scharfheimlich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:33 PM.


Advertisement
Log in to turn off these ads.