How to use Python requests to fake a browser visit a.k.a and generate User Agent?

Provide a User-Agent header: import requests url=”http://www.ichangtou.com/#company:data_000008.html” headers = {‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36’} response = requests.get(url, headers=headers) print(response.content) FYI, here is a list of User-Agent strings for different browsers: List of all Browsers As a side note, there is a pretty useful third-party package called … Read more

Detect IE version (prior to v9) in JavaScript

This is my preferred way of doing it. It gives maximum control. (Note: Conditional statements are only supported in IE5 – 9.) First set up your ie classes correctly <!DOCTYPE html> <!–[if lt IE 7]> <html class=”lt-ie9 lt-ie8 lt-ie7″> <![endif]–> <!–[if IE 7]> <html class=”lt-ie9 lt-ie8″> <![endif]–> <!–[if IE 8]> <html class=”lt-ie9″> <![endif]–> <!–[if gt … Read more