Commit 9db65425 by yangchen

添加默认 cookie 需观察何时失效

parent 3a3a77d3
...@@ -47,6 +47,7 @@ public class TouTiaoAccountParse { ...@@ -47,6 +47,7 @@ public class TouTiaoAccountParse {
public static TouTiaoAccount getTouTiaoAccountInfoByName(String name, Proxy proxy){ public static TouTiaoAccount getTouTiaoAccountInfoByName(String name, Proxy proxy){
String url = "https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset=0&format=json&keyword="+URLCodeUtil.getURLEncode(name, "utf-8")+"&autoload=true&count=20&en_qc=1&cur_tab=4&from=media&pd=user&timestamp="+System.currentTimeMillis(); String url = "https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search&offset=0&format=json&keyword="+URLCodeUtil.getURLEncode(name, "utf-8")+"&autoload=true&count=20&en_qc=1&cur_tab=4&from=media&pd=user&timestamp="+System.currentTimeMillis();
headerMap = Tools.getTouTiaoHeader(); headerMap = Tools.getTouTiaoHeader();
headerMap.put("cookie", "s_v_web_id=58999cab9d5be664e02f961e52e59269");
TouTiaoAccount tta = null; TouTiaoAccount tta = null;
try { try {
String htmlBody = downloadHtml(url, proxy, headerMap); String htmlBody = downloadHtml(url, proxy, headerMap);
...@@ -72,6 +73,8 @@ public class TouTiaoAccountParse { ...@@ -72,6 +73,8 @@ public class TouTiaoAccountParse {
public static TouTiaoAccount getTouTiaoAccountInfoByUserId(String user_id, Proxy proxy){ public static TouTiaoAccount getTouTiaoAccountInfoByUserId(String user_id, Proxy proxy){
String url = "https://www.toutiao.com/c/user/"+user_id+"/"; String url = "https://www.toutiao.com/c/user/"+user_id+"/";
headerMap = Tools.getTouTiaoHeader(); headerMap = Tools.getTouTiaoHeader();
headerMap.put("cookie", "s_v_web_id=58999cab9d5be664e02f961e52e59269");
TouTiaoAccount tta = null; TouTiaoAccount tta = null;
try { try {
String htmlBody = downloadHtml(url, proxy, headerMap); String htmlBody = downloadHtml(url, proxy, headerMap);
......
...@@ -46,7 +46,9 @@ public class TouTiaoSearchParse { ...@@ -46,7 +46,9 @@ public class TouTiaoSearchParse {
public static Map<String,Object> touTiaoSearchByWord(String url,Proxy proxy) throws Exception{ public static Map<String,Object> touTiaoSearchByWord(String url,Proxy proxy) throws Exception{
String htmlBody = null; String htmlBody = null;
try { try {
htmlBody = downloadHtml(url, proxy, HeaderTool.getCommonHead()); Map<String, String> header = HeaderTool.getCommonHead();
header.put("cookie", "s_v_web_id=58999cab9d5be664e02f961e52e59269");
htmlBody = downloadHtml(url, proxy, header);
if(htmlBody != null){ if(htmlBody != null){
Map<String,Object> dataMap = parseHtmlBySearch(htmlBody); Map<String,Object> dataMap = parseHtmlBySearch(htmlBody);
if(dataMap!=null && dataMap.size()>0){ if(dataMap!=null && dataMap.size()>0){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment