跳至主要内容

博文

android lauch time fast app activity

资源加载 首先尽量避免将耗时操作直接写在Application的onCreate()中,可以采用异步或者IntentService的方式加载资源。 不要以静态变量的方式在Application中保存数据 画面渲染 为启动的Activity自定义一个Theme,指定一个闪屏画面相同的背景图片 < style name = "AppSplash" > < item name = "android:windowBackground" > @mipmap/splash_bg </ item > </ style > 将新的Theme应用到设置到AndroidManifest.xml中LauncherActivity中 < activity android:name = ".MainActivity" android:theme = "@style/AppWelcom" > < intent-filter > < action android:name = "android.intent.action.MAIN" /> < category android:name = "android.intent.category.LAUNCHER" /> </ intent-filter > </ activity > 在MainActivity中需要设置回原来的Theme public class MainActivity extends AppCompatActivity { @Override protected void onCreate( Bundle savedInstanceState) { setTheme( R .style. AppTheme ); super .onCreate(savedInstanceState); setContentView( R .lay...

go spider example hello golang crawler

package main import ( "github.com/PuerkitoBio/goquery" "github.com/hu17889/go_spider/core/common/page" "github.com/hu17889/go_spider/core/pipeline" "github.com/hu17889/go_spider/core/spider" ) type MyPageProcesser struct { } func NewMyPageProcesser() *MyPageProcesser { return &MyPageProcesser{} } // Parse html dom here and record the parse result that we want to Page. // Package goquery (http://godoc.org/github.com/PuerkitoBio/goquery) is used to parse html. func (this *MyPageProcesser) Process(p *page.Page) { query := p.GetHtmlParser() query.Find("td div[class='flex-middle']").Each(func(i int, s *goquery.Selection) { println(s.Text()) }) } func (*MyPageProcesser) Finish() { } func main() { spider.NewSpider(NewMyPageProcesser(), "TaskName"). AddUrl("http://101.200.54.63/", "html").    // start url, html is the responce type ("html" or "json...

python socket

//client import socket cl=socket.socket(socket.AF_INET,socket.SOCK_STREAM) cl.connect(("101.200.54.63",80)) cl.send("GET / HTTP/1.1\r\nHost: 101.200.54.63\r\n\r\n") rp=cl.recv(4096) print rp