原创 spring boot 讀取 resources 下的文件,把文件內容讀到String中
File file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX+"static/detect.js"); String result = IOUtils.toS
原创 spring cloud 項目 用本地docker 打包鏡像
目錄結構 每一個模塊 都有一個 Dockerfile 文件 ,這個文件 可以 把jar 包變成一個docker 鏡像文件 文件內容,引入一個 openjdk:8-jre 的環境,在這個環境中 ,把jar包添加進去,編譯成一個docke
原创 java 獲得控制檯輸出的內容
//獲得控制檯內容 PrintStream oldPrintStream = System.out; //將原來的System.out交給printStream 對象保存 ByteArra
原创 suning 下單接口 報商品異常火爆的解決辦法
蘇寧下單接口 分爲兩步,第一步將商品添加進購物車,第二步提交訂單,返回訂單id 正常使用電腦瀏覽器 使用手機瀏覽器,就可以正常下單 其中兩個重要的接口就是 添加商品到購物車 提交訂單 我們抓取這兩個接口 這兩個接口中的 d
原创 java 正則匹配字符串
String pattern = "(actId.*)"; // 創建 Pattern 對象 Pattern r = Pattern.compile(pattern); M
原创 java url 中文編解碼
public static String getURLEncoderString(String str) { String result = ""; if (null == str) {
原创 python requests庫 響應中文亂碼
response = requests.request("POST", url, headers=headers, data = payload) html=response.content html_doc=
原创 python selenium 刷新頁面後 不能定位到元素
time.sleep(2) browser.switch_to.window(browser.window_handles[0])
原创 python selenium 執行 js
#點擊確定 browser.find_element_by_xpath('/html/body/div[4]/div[14]/div/div/a[2]').click() #下面獲取的三個參數,都不能下單,可能
原创 python selenium 設置cookie
# 1.用於將cookie字符串轉換爲對象,因爲後面add_cookie需要傳字典進去 def ParseCookiestr(cookie_str): cookielist = [] for item in cookie
原创 pip 的代理
pip install selenium -i https://mirrors.ustc.edu.cn/pypi/web/simple/ pip install requests -i https://mirrors.ustc.edu.c
原创 spring cloud @CrossOrigin 註解 報錯 has been blocked by CORS policy: The 'Access-Control-Allow-Origin'
瀏覽器訪問接口失敗,不返回任何狀態碼,查看後發現,把方法的@CrossOrigin註解掉就可以了 has been blocked by CORS policy: The 'Access-Control-Allow-Origin' h
原创 java 線程池等待所有線程返回結果
//開始多線程任務 public Map<String, String> start(List<PddAccount> list) throws InterruptedException { CountDown
原创 手機端 和 電腦端 跨域修改cookie
我們都知道cookie 是有域的限制的,要想得到baidu.com 這個 域的cookie ,那麼自己的域名必須在 baidu.com 或者 baidu.com之下,比如 xxx.baidu.com. 利用 hosts 可以很方便的把一個
原创 win10 搭建 php 環境
下載 apache http 服務器 https://de.apachehaus.com/downloads/httpd-2.4.41-o111c-x64-vc15-r2.zip 下載php 5.6.40 https://phpdev.t