Suche richtige Header für HttpUtils_BlockingGet Aufruf

Begonnen von Tobias, 07 September 2016, 11:10:16

Vorheriges Thema - Nächstes Thema

Tobias

Hi,
ich möchte automatisiert ein paar cover in meine aktuelle Playlist einfügen. Dazu habe ich eine Webseite ausgemacht, die dafür ganz passabel ausschaut.
Rufe ich die URL in meinem Firefox auf so wird mir auch das cover angezeigt.
Rufe ich die URL allerdings per FHEM auf, so wird eine Warnseite mit Aufforderung einer Captchas zurückgegeben. Irgendetwas muss also noch fehlen.....

zb. URL:  http://www.albumartexchange.com/covers?q=Something+Stupid+%28with+Nicole+Kidman%29&fltr=ALL&sort=TITLE&status=RDY&size=any&apply-filter=

meine Funktion:sub Utils_FileNavigator_GetCover($$$) {
    my ($device, $artist, $title) = @_;
    my $HttpResponse;
    my $HttpResponseErr;
    my $hash = $defs{$device};

    # http://www.albumartexchange.com/covers?q=Something+Stupid+%28with+Nicole+Kidman%29&fltr=ALL&sort=TITLE&status=RDY&size=any&apply-filter=
    my $url  = "http://www.albumartexchange.com/covers?";
       $url .= "&fltr=ALL";
       $url .= "&sort=TITLE";
       $url .= "&status=RDY";
       $url .= "&size=any";
       $url .= "&apply-filter=";
       $url .= "&q=" . uri_escape($artist ." : ". $title);

    Log3 $hash->{NAME}, 3, "GetCover: Hole URL: ". $url;
    my $param = {     url         => $url,
                      timeout     => 5,
                      hash        => $hash,    # Muss gesetzt werden, damit die Callback funktion wieder $hash hat
                      method      => "GET",     # Lesen von Inhalten
                      #httpversion => "1.1",
                      #header      => "User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22m"
                      header     => "User-Agent:Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0"
                  };
    ($HttpResponseErr, $HttpResponse) = HttpUtils_BlockingGet($param);
   
    if(length($HttpResponseErr) > 0) {
      Log3 $hash->{NAME}, 3, "GetCover: Fehler beim abrufen der Daten";
      Log3 $hash->{NAME}, 3, "GetCover: " . $HttpResponseErr;
    }

    return $HttpResponse;
}


Zurück kommt allerdings das:
Zitat<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Image Verification</title>
<meta name="robots" content="noindex,follow,noarchive">

<style>
   .sep { border-bottom: 1px black dotted; }
</style>

<script type="text/javascript" language="javascript">
<!--
   if(top.location.host!=self.location.host){parent.location.href=location.href;}
// -->
</script>

</head>
<body bgcolor="#EEEEEE" text="#000000" link="#CC0000" vlink="#CC0000" alink="#CC0000">

<table border="0" cellspacing="0" cellpadding="0" width="70%" align="center">
   <tr>
      <td valign="top">
         <div align="center"><img src="/blockscript/detector.php?blockscript=showlogo" border="0" alt="" width="467" height="60"></div><br><br>

         

         <table border="0" cellspacing="1" cellpadding="1" width="100%" bgcolor="#333333"><tr><td bgcolor="#FFFFFF" style="padding:2px;">   <form method="POST" action="/covers?">
   <input type="hidden" name="blockscript" value="captcha">
   <input type="hidden" name="x" value="5gHtU76rd4IK6/9dpkBBQg+D+TkQ1yJkQT4uCiXqsZHCNyiiOOUZRc6jWSQaCueBVEgejJjb8BnTeNu989oISMTZjKwQvoDHmAokCLmE">
   <input type="hidden" name="url" value="/covers?">
   <h3>Image Verification</h3>

   Please enter the five characters you see in the box below and click the &quot;Submit&quot; button.<br>
   Doing so helps prevent automated programs from abusing this website.<br><br>

   <table border="0" cellspacing="0" cellpadding="5">
      <tr>
         <td align="right" nowrap valign="top">&nbsp;</td>
         <td nowrap><img src="/blockscript/detector.php?blockscript=sci&amp;x=5gHtU76rd4IK6%2F9dpkBBQg%2BD%2BTkQ1yJkQT4uCiXqsZHCNyiiOOUZRc6jWSQaCueBVEgejJjb8BnTeNu989oISMTZjKwQvoDHmAokCLmE" border="0"></td>
      </tr>
      <tr>
         <td align="right" nowrap valign="top"><b>Characters: </b></td>
         <td nowrap><input name="val" type="text" size="20"> <input type="submit" value="Submit"></td>
      </tr>
   </table>
   </form></td></tr></table><br><br>
      </td>
   </tr>
   
</table>
</body>
</html>

Jemand eine Idee??
Maintainer: Text2Speech, TrashCal, MediaList

Meine Projekte: https://github.com/tobiasfaust
* PumpControl v2: allround Bewässerungssteuerung mit ESP und FHEM
* Ein Modbus RS485 zu MQTT Gateway für SolarWechselrichter

Markus Bloch

Versuch mal den User-Agent-Header mit Leerzeichen zu senden:

header     => "User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0"

Bei mir reagiert die Seite momentan garnicht. Ich bekomme ein Timeout.

Gruß
Markus
Developer für Module: YAMAHA_AVR, YAMAHA_BD, FB_CALLMONITOR, FB_CALLLIST, PRESENCE, Pushsafer, LGTV_IP12, version

aktives Mitglied des FHEM e.V. (Technik)