Skip to content

Instantly share code, notes, and snippets.

server:
http_listen_address: 0.0.0.0
http_listen_port: 9080
positions:
filename: /tmp/positions.yaml
clients:
- url: url
@Terryhung
Terryhung / api test
Created September 22, 2021 17:04
api test
curl -X POST \
https://enurl.app/v1/anon_shorten \
-H 'Accept: */*' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Host: enurl.app' \
-H 'Postman-Token: fee2d748-ebe7-46d7-a2bd-0189567bb524,48e1c73d-c1b3-4eb4-a006-3692a27f9fa8' \
-H 'User-Agent: PostmanRuntime/7.15.0' \
-H 'accept-encoding: gzip, deflate' \
class Solution:
# 0<= value <= 100
base = 101
# leetcode popular prime number
p = 10 ** 9 + 7
def findLength(self, nums1: List[int], nums2: List[int]) -> int:
l = 0
r = min(len(nums1), len(nums2))
def forward(self, feature):
for f in feature:
f = torch.from_numpy(f)
f = f.float()
lstm_out, self.hidden = self.lstm(
f.view(1, 1, len(f)), self.hidden)
tag_space = self.hidden2tag(lstm_out.view(1, self.hidden_dim))
tag_scores = F.log_softmax(tag_space, dim=1)
def lower_df(df):
pattern = re.compile('\W+')
for field in ['name', 'category_name', 'brand_name', 'item_description']:
_str = list(map(
lambda x: re.sub(pattern, ' ', x),
df[field].str.lower()
))
df[field] = _str
public static String AddDocHead(String s) throws Exception {
String _s = "<style> .article{padding-left: 18px;padding-right: 18px;padding-top: 15px;word-break: break-all}.article-header{font-size: 27px;color: #1a1a1a}.article-info{font-size: 16px;color: #c2c2c2;margin-top: 18px;margin-bottom: 18px}.article-content{margin-top: 18px;font-size: 22px;color: #818181}.main-image{width: 100%;max-height: 500px;margin-top: 20px;margin-bottom: 20px}hr{margin-top: 20px;color: #f5f5f5} img{width: 100%}</style>".concat(s);
return _s;
}
public static void Parsing() throws Exception {
String url = "http://www.cna.com.tw/news/aloc/201710030325-1.aspx";
Document doc = Jsoup.connect(url)
// Java
//without image url
public static void AddDocHead(Elements doc) throws Exception {
Element head = doc.first();
head.prepend("<style>.article-header{content: '';background: linear-gradient(to top, #000 1rem,#fff 40rem,#fff 100%);height: 5rem;display: block;}.main-image{width: 100%;max-height: 700px;opacty: 0.9}.article-content{background-color: #fff;position: absolute;width: 90%;z-index: 1;margin-left: 4%; margin-right: 5%;margin-top: -2rem;font-size: 25px; padding-left: 5px; padding-right: 5px}.article-header:after {content: '';background: #000;background: -moz-linear-gradient(top, #000 28%, #fff 58%, #fff 100%);background: -webkit-linear-gradient(top, #000 22rem,#fff 40rem,#fff 100%);background: linear-gradient(to bottom, #000 22rem,#fff 40rem,#fff 100%);height: 40rem;display: block;} .article-content img{width: 100%} div{white-space: pre-wrap; white-space: -moz-pre-wrap; word-wrap: break-word;}</style>");
}
// with image url
public static void AddDocHead(Elements
//JAVA
public static void AddDocHead(Elements doc) throws Exception {
Element head = doc.first();
head.prepend("<style>.article-header{content: '';background: linear-gradient(to top, #000 1rem,#fff 40rem,#fff 100%);height: 35rem;display: block;}.main-image{width: 100%;max-height: 700px;opacty: 0.9}.article-content{background-color: #fff;position: absolute;width: 90%;z-index: 1;margin-left: 4%; margin-right: 5%;margin-top: -2rem;font-size: 25px; padding-left: 5px; padding-right: 5px}.article-header:after {content: '';background: #000;background: -moz-linear-gradient(top, #000 28%, #fff 58%, #fff 100%);background: -webkit-linear-gradient(top, #000 22rem,#fff 40rem,#fff 100%);background: linear-gradient(to bottom, #000 22rem,#fff 40rem,#fff 100%);height: 40rem;display: block;} .article-content img{width: 100%}</style>");
}
public static void Parsing() throws Exception {
String url = "http://www.cna.com.tw/news/aloc/201710030325-1.aspx";
Document doc = Jsoup.connec
// JAVA
public static void parsing() throws exception {
string url = "http://www.cna.com.tw/news/aloc/201710030325-1.aspx";
document doc = jsoup.connect(url)
.header("user-agent", "mozilla/5.0 (linux; android 7.0; samsung sm-g950u build/nrd90m) applewebkit/537.36 (khtml, like gecko) samsungbrowser/5.2 chrome/51.0.2704.106 mobile safari/537.36")
.get();
string target = "div.news_article";
string remove = "script, button";
//Java
public static String ParsingHost() throws Exception {
String url = "http://www.cna.com.tw/news/aloc/201710030325-1.aspx";
URL aURL = new URL(url);
String host = aURL.getHost();
return host;
}