vbauer / manet

Website screenshot service powered by Node.js, SlimerJS and PhantomJS
MIT License
575 stars 102 forks source link

How to change user agent? #32

Closed webtrend closed 9 years ago

webtrend commented 9 years ago

I have been trying to capture screenshots of mobile webpages by changing the user agent. However, when I provide an iphone user agent as a parameter, I am just getting a blank screen.

Here is the command I am issuing

 http://myserverip:8891/?url=cnn.com&format=jpg&quality=0.5&agent=Mozilla%2F5.0%28iPhone%3BU%3BCPUiPhoneOS4_0likeMacOSX%3Ben-us%29AppleWebKit%2F532.9%28KHTML%2ClikeGecko%29Version%2F4.0.5Mobile%2F8A293Safari%2F6531.22.7

The error logged by the server is as follows:

 debug: Execution time: 1.44 sec
 debug: Process finished work: eyJ1cmwiOiJodHRwOi8vd2lja2VkZmlyZS5jb20iLCJhZ2VudC                                   I6Ik1vemlsbGEvNS4wKGlQaG9uZTtVO0NQVWlQaG9uZU9TNF8wbGlrZU1hY09TWDtlbi11cylBcHBsZV                                   dlYktpdC81MzIuOShLSFRNTCxsaWtlR2Vja28pVmVyc2lvbi80LjAuNU1vYmlsZS84QTI5M1NhZmFyaS                                82NTMxLjIyLjciLCJmb3JtYXQiOiJqcGciLCJxdWFsaXR5IjowLjV9
 error: Error while sending file: ENAMETOOLONG, stat '/tmp/eyJ1cmwiOiJodHRwOi8vd2                                lja2VkZmlyZS5jb20iLCJhZ2VudCI6Ik1vemlsbGEvNS4wKGlQaG9uZTtVO0NQVWlQaG9uZU9TNF8wbG                                lrZU1hY09TWDtlbi11cylBcHBsZVdlYktpdC81MzIuOShLSFRNTCxsaWtlR2Vja28pVmVyc2lvbi80Lj                                AuNU1vYmlsZS84QTI5M1NhZmFyaS82NTMxLjIyLjciLCJmb3JtYXQiOiJqcGciLCJxdWFsaXR5IjowLj                                V9.jpg'

The error disappears when I don't use an agent. BTW, I am using slimerjs engine to render the pages.

vbauer commented 9 years ago

There is a problem with a long file name: https://github.com/vbauer/manet/issues/10 Parameter "User-Agent" is a part of temporary filename (in base64).

I hope I will have some free time in the nearest future to fix #10.

webtrend commented 9 years ago

ok, understood. Thanks