Created
April 13, 2012 05:23
-
-
Save tlxue/2373919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var topic_names = ['摄影','阅读','设计','电子商务','投资','电影','音乐','法律','旅行','美食','游戏','历史','文学','篮球','创业','自然科学','健康','情感','冷知识','互联网','商业','体育','汽车','教育'], | |
urls = []; | |
function request(url){ | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open( "GET", url, false ); | |
xmlHttp.send( null ); | |
return xmlHttp.responseText; | |
} | |
function getURL(topic_name){ | |
var url, | |
topic_url = 'http://www.zhihu.com/topic/' + topic_name; | |
url = request(topic_url).match(/src=".+" class="xuu"><\/a>/)[0].match(/http.+\.jpg/)[0]; | |
return url; | |
} | |
for(var i = 0; i<topic_names.length; i++){ | |
urls.push(getURL(topic_names[i])); | |
} | |
console.log(urls); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment