网页制作时,如何实现用手机打开网页时加载另一个JS文件 如何获取PhantomJS打开网页时加载的JS资源
\u624b\u673a\u767b\u9646\u7f51\u9875\u65f6\u5982\u4f55\u8bbe\u7f6e\u81ea\u52a8\u8df3\u8f6c\u5230\u53e6\u4e00\u4e2a\u9875\u9762\uff0cjs\u4ee3\u7801\u600e\u4e48\u5199\uff1f
function isMobile() {
if((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)))
return true;
else
return false;
}
var urlMobile='http://www.163.com';//\u624b\u673a\u8df3\u8f6c\u7684\u9875\u9762
if(isMobile() !== false)
window.location.href=urlMobile;
\u3000\u3000js\u5e76\u4e0d\u80fd\u5b9e\u73b0\u5982\u6b64\u7684\u529f\u80fd\u3002
\u3000\u3000\u56e0\u4e3ajs\u6587\u4ef6\u672c\u8eab\u5c31\u662f\u88ab\u52a0\u8f7d\u8fdb\u6765\u7684,\u6240\u4ee5\u5f53js\u6587\u4ef6\u672a\u88ab\u52a0\u8f7d\u7684\u65f6\u5019,\u5b83\u662f\u65e0\u6cd5\u5bf9\u4e4b\u524d\u52a0\u8f7d\u8fdb\u6765\u7684\u6587\u4ef6.\u53c2\u8003\u4ee3\u7801\uff1a
\u3000\u3000dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.loadImages"] = False # \u7981\u6b62\u52a0\u8f7d\u56fe\u7247,\u9ed8\u8ba4\u52a0\u8f7d
dcap["phantomjs.page.settings.resourceTimeout"] = 5000 # \u8d85\u65f6\u65f6\u95f4\uff0c\u5355\u4f4d\u662f ms
if headers == None:
dcap["phantomjs.page.settings.userAgent"] = tool.get_headers()
else:
dcap["phantomjs.page.settings.userAgent"] = headers
driver = webdriver.PhantomJS(desired_capabilities=dcap)
driver.get(url)
import pprint
pprint.pprint(dir(driver))
try:
driver.find_element_by_css_selector('#mod_columns_tab').click()
except:
pass
if sellp_time:
time.sleep(sellp_time)
html = driver.page_source
driver.close()
return html
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
}else{
}
绛旓細1銆佷互灏忕背鎵嬫満涓轰緥锛岄鍏堝湪鎵嬫満涓婂埄鐢≦Q鎺ユ敹涓涓狧TML鏂囦欢銆2銆佺劧鍚庡湪鎵嬫満QQ涓偣鍑昏HTML鏂囦欢锛岄夋嫨鐢ㄥ叾浠栧簲鐢ㄦ墦寮銆3銆佺劧鍚庡湪鍏朵粬搴旂敤涓夋嫨娴忚鍣紝鐐瑰嚮涓嬫柟鐨勪粎姝や竴娆°4銆佹墦寮瀹屾垚鍚庣殑鏁堟灉濡傚浘鎵绀猴紝HTML鏂囦欢鎴愬姛琚湪娴忚鍣ㄤ腑鎵撳紑銆
绛旓細鐐瑰嚮缃戦〉娴忚璁剧疆 鎵惧埌娴忚鍣ㄦ爣璇嗭紙UA锛夈鐐瑰嚮鍙充晶鎵嬫満鐗堬紝鏀规垚鐢佃剳鐗 杩欐牱锛屽氨鍙互鐢ㄦ墜鏈烘墦寮鐢佃剳缃戦〉浜嗐
绛旓細鏈変釜鍝嶅簲寮忓竷灞鐨勬蹇点備富瑕佸簲鐢ㄤ笅闈㈣繖绉嶆柟寮忥紝涓嬮潰鎰忔濇槸褰撳睆骞曞ぇ浜240px鏃讹紝鎵ц閲岄潰鐨勬牱寮忋備綘鍙互鍙傝僢ootstrap鍓嶇妗嗘灦锛屽畠杩欐柟闈㈠仛鐨勪笉閿 media screen and (max-width:240px){ .box{width:200px;} .title{color:red;} }
绛旓細1銆佹墦寮浣犵殑娴忚鍣ㄣ2銆佹墦寮娴忚鍣ㄤ箣鍚庯紝鎵惧埌鍙充笂鏂硅缃寜閽3銆佺偣鍑诲叏灞忓嵆鍙紝涔熷彲浠ョ洿鎺ユ寜閿洏鐨凢11銆4銆佸揩鎹烽敭闇瑕佽嚜宸辫缃紝閫氬父榛樿閫氱敤鏄疐N+F11锛屽悓鏃舵寜浣忊淔n+F11鈥濈粍鍚堥敭鏉ュ紑鍚叏灞忥紝鍐嶆寜涓娆″嵆鍙鍑哄叏灞忋
绛旓細绗竴姝ワ細鍦鏂囦欢绠$悊鍣ㄤ腑鎵惧埌闇瑕鎵撳紑鐨剈rl鏂囦欢锛屽苟閫夋嫨鎵撳紑鏂瑰紡涓衡滄枃鏈濄傝涓嬪浘鎵绀猴細绗簩姝ワ細鐢ㄢ滄枃鏈濇柟寮忔墦寮鍚庯紝浼氬脊鍑烘煡鐪嬪伐鍏凤紝鐐瑰嚮浣跨敤HTML鏌ョ湅鍣ㄦ墦寮銆傝涓嬪浘鎵绀猴細绗笁姝ワ細鏈搴曚笅涓琛屾槸缃戠粶鍦板潃锛屼粠鈥滐紳鈥濆彿鍚庨潰寮濮嬮夋嫨锛岀洿鎺ュ鍒躲傝涓嬪浘鎵绀猴細绗洓姝ワ細鎵撳紑娴忚鍣ㄥ湪娴忚鍣ㄦ悳绱㈡爮涓矘璐磚rl...
绛旓細1. 浣跨敤娴忚鍣ㄧ殑寮鍙戣呭伐鍏凤細鍦澶у鏁扮幇浠f祻瑙堝櫒涓紝渚嬪Chrome銆丗irefox鍜孍dge锛屼綘鍙互浣跨敤寮鍙戣呭伐鍏锋潵妯℃嫙绉诲姩璁惧骞跺姞杞鎵嬫満鐗缃戦〉銆備互涓嬫槸浣跨敤Chrome娴忚鍣ㄧ殑姝ラ锛鎵撳紑Chrome娴忚鍣紝骞惰浆鍒颁綘鎯宠鎵撳紑鐨勭綉椤点傚彸閿偣鍑荤綉椤典笂鐨勪换鎰忎綅缃紝骞堕夋嫨鈥滄鏌モ濇垨鑰呯洿鎺ヤ娇鐢ㄥ揩鎹烽敭Ctrl+Shift+I锛圵indows锛夋垨Cmd+...
绛旓細涓嶈兘锛岄櫎闈炴湁浠ュ紑鍙鎵嬫満缃戠珯鐨勬爣鍑嗘妸椤甸潰鎻愬嚭鏉ワ紝鏀剧疆鏈嶅姟鍣ㄧ┖闂翠笂閾炬帴濂藉煙鍚嶈闂紝鏃㈢劧浣犵殑h5椤甸潰搴旂敤宸茬粡鏈変簡锛屽湪绉绘鍒版墜鏈洪〉闈㈢増涔熺畝鍗曚簡鍚э紝闄や簡娑夊強鎺у埗鎵嬫満搴曞眰鐨勬病娉瀹炵幇浠ュ銆
绛旓細1 /6 棣栧厛锛屾垜浠鍦ㄦ墜鏈涓壘鍒板苟鎵撳紑娴忚鍣ㄣ2 /6 缃戝潃杈撳叆妗嗕腑杈撳叆鐧惧害缁忛獙缃戝潃锛岃繘鍏ョ櫨搴︾粡楠屻傛垜浠彲浠ュ彂鐜锛岀綉椤鑷傚簲浜嗘垜浠殑鎵嬫満銆3 /6 鎺ヤ笅鏉ユ垜浠氳繃淇敼璁剧疆鍙栨秷缃戦〉鐨勮嚜閫傚簲銆傚鍥撅紝鐐瑰嚮涓嬫柟鐨勪笁鏉℃í绾跨殑鍥炬爣銆4 /6 鍦ㄥ脊鍑虹殑搴曢儴绐楀彛涓紝鎴戜滑鎵惧埌骞剁偣鍑昏缃5 /6 鎺ョ潃锛屾垜浠壘鍒扳滄祻瑙...
绛旓細1.鎵撳紑鍗庝负娴忚鍣紝鐐瑰嚮鍙充笅瑙掔殑鈥滀笁涓偣鈥濄2.娴忚鍣ㄥ姛鑳藉尯寮瑰嚭鍚庯紝鐐瑰嚮鎵撳紑鈥滃伐鍏风鈥濄備笁銆鍦宸ュ叿绠变腑鎵惧埌鈥滆闂绠楁満鐗堚濆浘鏍囷紝鐒跺悗鍗曞嚮鎵撳紑銆4.姝ゆ椂娴忚鍣ㄩ鏍间細鑷姩鍒囨崲鍒癙C椋庢牸锛缃戦〉鍙樻垚PC缃戦〉銆鎵嬫満涓婃煇涓綉绔欑敤鍚勭娴忚鍣ㄩ兘鎵撲笉寮锛屽彧鏄崟涓綉绔欐墦涓嶅紑锛屽埆浜虹殑鎵嬫満鍗撮兘鑳鎵撳紑锛屾庝箞鍥炰簨锛...
绛旓細1锛岄鍏鎵撳紑Uc娴忚鍣鎵嬫満鐗堬紝鐒跺悗鐐瑰紑搴曚笅鐨勮彍鍗曟寜閽紱2锛屽垏鎹㈠埌璁剧疆鍐嶇偣鍑昏缃寜閽紱3锛岀劧鍚庡簳涓嬫湁涓祻瑙堣缃紝鎶婂畠鐐瑰紑锛4锛岀劧鍚庤缃负chrome鎵嶅彲浠ョ敤鐢佃剳鐗堬紱杩欐牱灏辨垚鍔熶簡銆傛庢牱鎶婃墜鏈烘闈㈡崲鎴缃戦〉锛1 /6 鎵惧埌鎵嬫満妗岄潰涓婄殑娴忚鍣紝鐐瑰嚮鎵撳紑銆2 /6 鐐瑰嚮鍙充笅瑙掍笁鏉℃í鏉犵殑鏍囧織銆3 /6 鎵惧埌宸ュ叿绠...