代码拉取完成,页面将自动刷新
同步操作将从 songbl/stata_do 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
qui{
preserve
if "`cls'"!=""{
cls
}
if "`page'"==""{
local page=1
}
if "`page'"!=""{
if `page'==1{
local url http://www.statalist.org/forums/forum/general-stata-discussion/general
}
else {
local url http://www.statalist.org/forums/forum/general-stata-discussion/general/page`page'
}
}
if "`sort'"!=""{
if "`sort'"=="title"{
local url="`url'"+"?filter_sort=title"
}
else if "`sort'"=="last"{
local url="`url'"+"?filter_sort=lastcontent"
}
else if "`sort'"=="start"{
local url="`url'"+"?filter_sort=created"
}
else if "`sort'"=="replie"{
local url="`url'"+"?filter_sort=replies"
}
else if "`sort'"=="member"{
local url="`url'"+"?filter_sort=author"
}
else if "`sort'"=="like"{
local url="`url'"+"?filter_sort=votes"
}
else{
dis as error `"sort() : invalid sort type"'
exit 198
}
}
clear
tempfile html_text
cap copy "`url'" "`html_text'.txt", replace
local times = 0
while _rc ~= 0 {
local times = `times' + 1
sleep 1000
cap copy `"`URL'"' "`html_text'.txt", replace
if `times' > 5 {
n dis as text _col(3) `"{browse "`url'":(contacting https://www.statalist.org/forums)}"'
disp as error "Internet speeds is too low to get the data"
exit 601
}
}
infix strL v 1-100000 using "`html_text'.txt", clear
keep if index(v, "js-topic-title") | index(v, "posts-count") | index(v, "views-count")
gen id = int((_n - 1)/3) + 1
egen year = seq(), from(1) to(3)
reshape wide v, i(id) j(year)
compress
drop id
replace v2 = ustrregexra(v2, ",","")
replace v3 = ustrregexra(v3, ",","")
gen post = ustrregexs(0) if ustrregexm(v2, "\d+$")
gen view = ustrregexs(0) if ustrregexm(v3, "\d+$")
rename v1 v
drop v2 v3
split v, p(`"<a href=""')
split v2, p(`"" class="topic-title js-topic-title">"')
split v22, p("</a>")
rename v21 link
rename v221 title
*replace title = ustrregexra(title, `"""',"")
*replace title = ustrregexra(title, "`","")
*replace title = ustrregexra(title, "'","")
keep link title post view
n dis as text _skip(70) "{bf:Hello, Songbl Stata}"
n dis as txt "{hline}"
n dis in text _col(5) "{bf:Topics}" _col(135) `"{bf:Posts}"' _col(145) `"{bf:Views}"'
n dis as txt "{hline}"
local n=_N
forvalues i = 1/`n' {
local link =link[`i']
local title=title[`i']
local post =post[`i']
local view =view[`i']
if "`line'"!=""{
n dis as text _col(2) `"{browse `"`link'"':- }"' _col(4) `"`title'"' _col(135) "`post'" _col(145) "`view'"
}
else{
n dis as red _col(4) `"{browse `"`link'"': `title'}"' _col(135) "`post'" _col(145) "`view'"
}
if "`gap'"!=""{
n dis ""
}
}
n dis as txt "{hline}"
n dis as text _col(3) `"{browse "`url'":(contacting https://www.statalist.org/forums)}"' _n
restore
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。