R
R
Roma Kozubiak2017-06-09 13:04:18
PHP
Roma Kozubiak, 2017-06-09 13:04:18

PHP parser. How to parse photos from the site in original size?

I made a parser that copies photos from each publication on the main page of the site.
But there is one problem, I copy photos from this site ( stvorenonaukoy.blogspot.com/) and this site is made on the blogger platform, so the photos are copied in 72x72 size, although they are in the normal size on the site.
On the site, the url of the photo is written in styles.
Here's what it looks like on the site I'm copying the photo from:

<div class="thumb">
               <a href="http://goruzont.blogspot.com/2017/04/blog-post_6440.html" style="background:url(https://1.bp.blogspot.com/-6vpIH5iqPYs/WPzlNdxsRpI/AAAAAAAAntU/d7U_Ch_6FiIPwosNL4tWwqBeXw8qwo2nACLcB/s1600/1424051.jpg) no-repeat center center;background-size:cover">

<span class="thumb-overlay"></span></a>
 </div>

Here is the parser code:
<?php
header('Content-type: text/html; charset=utf-8');
require 'phpQuery.php';

function print_arr($arr){
  echo '<pre>' . print_r($arr, true) . '</pre>';
}
 
$url = 'http://stvorenonaukoy.blogspot.com/';
$file = file_get_contents($url);
 
$doc = phpQuery::newDocument($file);
 
foreach($doc->find('.blog-posts .post-outer .post') as $article){
    $article = pq($article);
    $img = $article->find('.thumb a')->attr('style');
    
    $img."<br>"; if (preg_match('!background:url.(.+). no!',$img,$match)) { 
$imgurl = $match[1]; 
} else 
{echo "<img src = http://goruzont.blogspot.com".$item.">";}  
    
    echo "<img src='$imgurl'>";
}
?>

How can I copy the photo in the same size as on the website?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DENIS, 2017-06-09
@Creditpower2015

It gives 72*72 from the mobile version as I see it.
https://3.bp.blogspot.com/-sJKkDKsctvA/WTpqBZpeF6I... - mobile
https://3.bp.blogspot.com/-sJKkDKsctvA/WTpqBZpeF6I...
- full to the title. For example:
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
I don't know how it is in php, I work on asp.
Or replace /s72-c/ in the link with /s1600/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question