Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Androidでスクレイピングした話 / Talk of scraping with Android

futabooo
February 01, 2018

Androidでスクレイピングした話 / Talk of scraping with Android

futabooo

February 01, 2018
Tweet

More Decks by futabooo

Other Decks in Technology

Transcript

  1. 2 About me  4FOJPS&OHJOFFS4DSVN.BTUFSBUFVSFLB *OD  +BWB ,PUMJO (PMBOH

    5ZQF4DSJQU "OHVMBS+4  'BOUBTZ&BSUI;FSP T$3:FE 4QMBUPPO  GVUBCPPP ɹɹɹೋ઒ ོߒʢTakahiro Futagawaʣ
  2. 3 About eureka  ैۀһ਺  ໊ʢฏۉ೥ྸࡀʣ  ࣄۀ಺༰ 

    ࣗࣾαʔϏεاըɾ։ൃɾӡӦ  1BJST  $PVQMFT ձࣾ֓ཁ
  3. interface LoginService { @GET("/login") fun get(): Observable<ResponseBody> @FormUrlEncoded @POST("/login") fun

    login( @Field("session[email_address]") mail: String, @Field("session[password]") password: String, @Field("authenticity_token") authenticityToken: String): Observable<ResponseBody> }
  4. retrofit.create(LoginService::class.java).get() .flatMap { val reader = BufferedReader(InputStreamReader(it.byteStream())) val result =

    reader.readLines().filter(String::isNotBlank).toList() val token = Jsoup.parse(result.toString()) .select("form input[name=authenticity_token]").attr("value") } .subscribeBy( onNext = { val reader = BufferedReader(InputStreamReader(it.byteStream())) val result = reader.readLines().filter(String::isNotBlank).toList() val alert = Jsoup.parse(result.toString()) .select(“div.container li.bm-flash-item—alert").isNotEmpty() if (alert) { Timber.i("E-mail or Password is wrong") contract.failureLogin() return@subscribeBy } }, onError = { Timber.e(it, it.message) } )