需要有关从FileHost抓取图像的帮助

时间:2018-08-04 14:13:32

标签: php

我制作了此脚本,但主要问题是它们无法抓取图像。图片已上传但无法抓取我不知道该如何解决,因为imagetwist现在有多个域可供抓取

<?php
function upload_to_imagetwist_user($img,$data) {
    global $wb_config,$upload_profile;
    if(stristr($img,$wb_config['wb_path'])) $img=str_ireplace($wb_config['wb_path'],$wb_config['wb_url'],$img);
    $fid = $wb_config['upload_profiles'][$upload_profile]['feed'];
    if($wb_config['feeds'][$fid]['ftype']=='xxx') $safe = 0; else $safe = 1;

    $imageUrl = '';
    //login
    $user = $data['user_username'];
    $pass = $data['user_password'];
    $cookie = $wb_config['wb_path'].'adata/cookies/image_hosts_imagetwist';
    $pvars = array('op'=>'login','login'=>$user,'password'=>$pass,'submit'=>'Login');
    $page = curl_func_with_timeout('https://imagetwist.com/',$pvars,$cookie,'https://imagetwist.com/');
    echo '<textarea>'.htmlentities($page).'</textarea>';
    $uid = '';
    for($i=0;$i<12;$i++) $uid .= rand(0,9);
    //upload
    $upurl = cut_str($page,'<form name="url" enctype="multipart/form-data" action="','" method="post"');
    $sid = cut_str($page,'name="sess_id" value="','">');
    $url = $upurl.$uid.'&js_on=1&utype=reg&upload_type=url';
    echo $url;
    $pvars = array('url_mass'=>$img,'sess_id'=>$sid,'upload_type'=>'url','mass_upload'=>1,'thumb_size'=>'170x170','file_safe'=>$safe,'fld_id'=>0,'per_row'=>'1','tos'=>1,'url_1'=>'','url_1_public'=>1);
    print_r($pvars);
    $page = curl_func_with_timeout($url,$pvars,$cookie,'https://imagetwist.com/');
    echo '<textarea>'.htmlentities($page).'</textarea>';
    preg_match("~<textarea name='fn'>([a-zA-Z0-9]+)</textarea>~ism",$page,$match);
    $pvars = array('fn'=>$match[1],'st'=>'OK','op'=>'upload_result','per_row'=>'1');
    print_r($pvars);
    $page = curl_func_with_timeout('https://imagetwist.com/',$pvars,$cookie,$url);
    echo '<textarea>'.htmlentities($page).'</textarea>';
    //echo '<textarea>'.htmlentities($page).'</textarea>';
    preg_match("~<tr><td align=center><b>Code for forums:</b></td>\s+<td><input(.*?)value=\"(.*?)\"></td><td><input(.*?)></td></td></tr>~ism",$page,$match);
    //print_r($match);
    $imageUrl = $match[2];
    if(stristr($imageUrl,'imagetwist.com')) return $imageUrl;
    else return false;
}

0 个答案:

没有答案