반응형
- 2023-09-18 : First posting.
@hxxax__ 혜안 몰리와 띵띵땅땅 댄스
♬ 오리지널 사운드 - 혜안
### https://vt.tiktok.com/(\w+)/ 형태의 URI 일 경우.
이건 web client 를 돌리는 경우에만 iframe 형태의 Full URI 로 뽑아낼 수 있는거 같음.
아래는 FullURI 끄집어내는 code 일부분.
```[.linenums.lang-java]
RecoeveWebClient recoeveWebClient=new RecoeveWebClient();
recoeveWebClient.webClient.headAbs(shortURI)
.send()
.onSuccess(response -> {
if (response.statusCode()==200) {
// The response is a redirect, so get the followedRedirects().
List<String> followedURIs=response.followedRedirects();
String fullURI=followedURIs.get(followedURIs.size()-1);
System.out.println("Full TikTok URL: "+fullURI);
pl.req.response().putHeader("Content-Type","text/plain; charset=utf-8")
.end(fullURI, ENCODING);
}
else {
System.out.println("Sended shortURI.");
pl.req.response().putHeader("Content-Type","text/plain; charset=utf-8")
.end(shortURI, ENCODING);
}
recoeveWebClient.webClient.close();
})
.onFailure(throwable -> {
throwable.printStackTrace();
System.out.println("Sended shortURI.");
pl.req.response().putHeader("Content-Type","text/plain; charset=utf-8")
.end(shortURI, ENCODING);
recoeveWebClient.webClient.close();
});
```/
아래는
RecoeveWebClient.java
File.
```[.linenums.lang-java]
package recoeve.http;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.client.WebClient;
import io.vertx.ext.web.client.WebClientOptions;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class RecoeveWebClient {
public static final WebClientOptions options=new WebClientOptions().setMaxHeaderSize(16384).setFollowRedirects(true);
public WebClient webClient;
public long timerId;
public int timerN;
public RecoeveWebClient() {
webClient=WebClient.create(Recoeve.vertx, options);
timerN=0;
}
public void doUntilH1IsFound(HttpResponse response, PrintLog pl, int delay) {
timerId=Recoeve.vertx.setTimer(delay, timerHandler -> {
timerN++;
if (response.statusCode()==200) {
String body=response.bodyAsString();
Document document=Jsoup.parse(body);
// Select the first <h1> element and extract its text content
Elements h1Elements=document.select("title, h1");
if (h1Elements.isEmpty()&&timerN<7) {
doUntilH1IsFound(response, pl, delay+512);
}
else {
if (!h1Elements.isEmpty()) {
Element firstH1Element=h1Elements.first();
String h1Text=firstH1Element.text();
System.out.println("Content of the first <h1> tag: "+h1Text);
pl.req.response().putHeader("Content-Type","text/plain; charset=utf-8")
.end(h1Text, Recoeve.ENCODING);
}
else {
System.out.println("No <h1> tags found on the page.");
pl.req.response().putHeader("Content-Type","text/plain; charset=utf-8")
.end("No <h1> tag.", Recoeve.ENCODING);
}
}
}
});
}
public static void main(String... args) {
// Do nothing.
}
}
```/
### Recoeve.net 이용하기
다음과 같은 링크로 연결하면 https://recoeve.net/reco?uri=https://www.tiktok.com/@ganadaba/video/7280762870080556306&title=230527 ITZY - Cheshire 유나 직캠 2023 드림콘서트 #itzy #fancam #cheshire #dreamconcert #yuna&cats=[Music/Break]--K-Pop--FanCam 아래와 같이 뜸.
Direct reco example.
iframe of direct reco page.
Direct reco example.
iframe of direct reco page.
반응형
'[IT/Programming] > HTML related' 카테고리의 다른 글
트위터 트윗 퍼오기 (Embedding Twitter Tweet) (0) | 2023.10.25 |
---|---|
<link ref="canonical" href="..." /> 설정하기 (DISQUS config 활용) (0) | 2023.10.25 |
Mouse click 들 (left, right, wheel, wheel up, wheel down, back, forward) 구분해내기 (1) | 2023.10.25 |
댓글 플러그인 | 위젯 (SNS comment plug-in | widget) (3) | 2023.10.24 |
Learning Vert.x (0) | 2023.05.30 |
HTML docuK format ver. 2.1, short copiable version (2023-05-30) (0) | 2023.05.30 |
Interactive graph and chart in HTML (0) | 2023.03.10 |