I am scraping some url from a webpage and its showing fine on page, but when I insert the url into database it inserted some wierd like this
http://westseattleblog.com/event/west-seattle-church-listings/?instance_id=567059
my code
foreach($html->find('div[class=ai1ec-btn-group ai1ec-actions] a') as $element)
{
$url= $element->href;
$url1=mysql_real_escape_string($url);
$sql="insert into catlink(catlink) values('$url1')";
//echo $sql."<br>";
$query=mysql_query($sql);
//newpage
}
And when I start fetching the url from database and scraping one by one, it shows nothing.
my code
$sql1="select * from links limit 10";
$query1=mysql_query($sql1);
while($res=mysql_fetch_assoc($query1)){
$url=$res['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
// curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$page = curl_exec($ch);
curl_close($ch);
$dom = new simple_html_dom();
$html = $dom->load($page);
foreach($html->find("div") as $a){
echo $a->innertext;
}
//$separator = ' - ';
}