ホームページ バックエンド開発 C#.Net チュートリアル HttpClient は Web ページのソース コードをクロールします

HttpClient は Web ページのソース コードをクロールします

Dec 20, 2016 pm 12:00 PM
apache

インポート java.io.BufferedReader;

インポート java.io.InputStreamReader;

インポート java.text; .SimpleDateFormat;
import java.util.Date;
import java.util.List; ;
import java.util.zip.GZIPInputStream;
import org.apache.commons.httpclient.HttpClient; apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpStatus; commons.httpclient.SimpleHttpConnectionManager;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams; org.apache.commons.httpclient.params.HttpMethodParams;

/ **
* @author Liuwei
* 日付: 2009 年 12 月 18 日
*
* TODO
* HttpClient の補助クラス
* /
public class HttpClientHelper
{

/ **
* HttpClient の接続タイムアウト、読み取りデータのタイムアウト設定 (単位: ミリ秒)
* /
Public static Final int HTTPCLIENT_CONNECTION_TIMEOUT = 30000;
Public static Final int HTTPMETHOD_SO_TIMEOUT = 5000; ConnectionManager の管理 接続を閉じるかどうかwhen httpclientconnection
private static boolean alwaysClose = FALSE;
private static string defaultEncode = "UTF-8";

private static last DateFormat = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS "); **
* HttpClient 接続を取得し、関連するパラメーターを設定します
*
* @return
* /
public static HttpClient の getHttpClient()
{
HttpClient client = new HttpClient (new SimpleHttpConnectionManager (alwaysClose)); ionManagerParams managerParams = クライアント.getHttpConnectionManager() getParams() メソッド。
//接続タイムアウトを設定します (ミリ秒単位)
managerParams.setConnectionTimeout (HTTPCLIENT_CONNECTION_TIMEOUT);
//読み取りデータのタイムアウトを設定します (ミリ秒単位)
クライアントに戻ります。
/ * *
* HttpClient 接続を取得し、関連するパラメーターを設定します
*
* @parameter logonSite
* @parameter logonPort
* @parameter Protocol
* @return
* /
public static HttpClient の getHttpClient (最後の文字列 logonSite、最終解釈 logonPort 、最後の文字列プロトコル)
{
HttpClient client = new HttpClient(new SimpleHttpConnectionManager(alwaysClose));
client.getHostConfiguration() setHost(logonSite, logonPort, プロトコル)。
HttpConnectionManagerParams managerParams = client.getHttpConnectionManager() getParams() メソッド。
//接続タイムアウトを設定します (ミリ秒単位)
managerParams.setConnectionTimeout (HTTPCLIENT_CONNECTION_TIMEOUT);
//読み取りデータのタイムアウトを設定します (ミリ秒単位)
クライアントに戻ります。
プライベートstatic List getHeaders(MapHeaders)
{
List = ヘッダーの配列 new ();
if ( empty = header&& false == ヘッダー) .isEmpty() )
{
set> =entrySet header.entrySet();
for (enter エントリ:entrySet)
if (false == includeUserAgent
&& "UserAgent".equals(entry.getKey()))
{
includeUserAgent = TRUE;
}
headers(new headers()entry.getKey(),entry.getValue()))
} }

if (false == includeUserAgent)
{
headers.add(new headers(
"UserAgent",
"Mozilla/4.0( と互換性があります。MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 1.1.4322; .NET CLR 2.0 0.50727; Alexa ツールバー; MAXTHON 2.0)"));
}
Return Header;
}

Private static NameValuePair [] getPairs(Map POSTDATA)
{
if (null == | | POSTDATA postData.isEmpty())
{
return
}

文字列 , 文字列 >> =
INT DATALENGTH =
NameValuePair ] = 新しい NameValuePair[DATALENGTH]
INT I = 0;
For (entryentrySet)
{
double[i++] = new NameValuePair(entry.getKey(),entry.getValue());
return ペア
}

/ **
*Web コンテンツ情報のリクエスト
*
* @parameter HttpClient
* @parameter reqUrl
*パラメータ タイトル
* @parameter POSTDATA
*パラメータ エンコーディング
* @return
* /
public static string doRequest(HttpClient HttpClient, String reqUrl,
Map ヘッダー, MapPOSTDATA, String エンコーディング)
{
String htmlContent = NULL;
if (null == HttpClient )
{
Return htmlContent;

//エンコーディング設定のリクエスト

//ヘッダーリクエスト情報
ListSystem.out.println("[" + DATE_FORMAT.format(new Date()) + "] - doRequest - " + reqUrl); <br><br>//Post メソッド <br> if (null = POSTDATA!) <br>{ <br> PostMethod PostMethod = new EncodePostMethod(reqUrl,coding); <br>for (header tempHeader: header) <br>{ <br>postMethod.setRequestHeader(tempHeader); <br><br>//Post パラメータ設定 <br>NameValuePair[] = PARAMS getPairs(POSTDATA ; <br>Other<br>{ <br>) GetMethod getMethod = 新しい実装 getMethod(reqUrl); <br>for (head tempHeader: header) <br>{ <br>getMethod.setRequestHeader(tempHeader) <br>} <br><br>//Web ページのコンテンツを抽出 <br>htmlContent =executeMethod(HttpClient , getMethod, encoding, NULL) ); <br>} <br>Return htmlContent; <br><br> プライベート静的文字列 getWebSite(String reqUrl) <br>{ <br>String website = NULL; <br> if (null == reqUrl || reqUrl.isEmpty( )) <br>{ <br>Web サイトに戻る<br>} <br><br>文字列プレフィックス = "HTTP://"; <br>if (reqUrl.startsWith(prefix)) <br>{ <br>INT インデックス = reqUrl.substring(prefix.length()) IndexOf("/") + prefix.length (); <br>Website = reqUrl.substring(0,index); <br>} <br>Web サイトに戻る <br>} <br><br>/ ** <br>* HTTPMethod を列挙して Web ページのコンテンツを取得します <br>* <br>* @parameter HttpClient <br>* requestMethod <br>* パラメータのエンコーディング <br> * パラメータのウェブサイト <br>* @return <br>* / <br> private static string useMethod (HttpClient HttpClient, enum HTTPMethod requestMethod, エンコードされた文字列, 文字列 Web サイト) <br> { <br>String responseContent = NULL; ) <br>{ <br>return responseContent; <br>} <br><br>//暗号化されたデータをリクエストするかどうかを決定する <br> Boolean dataEncrypt = FALSE; <br>Header acceptEncoding = requestMethod.getRequestHeader(" エンコーディングを受け入れる");空 = acceptEncoding <br>。 && acceptEncoding.getValue() contains("gzip")) <br>{ <br>dataEncrypt = TRUE; <br><br>InputStream responseStream = NULL; <br>INT status = httpClient.executeMethod(requestMethod) <br>if(HttpStatus .SC_OK) == ステータス) <br>{ <br>responseStream = requestMethod.getResponseBodyAsStream(); <br>responseContent = getContentByStream(dataEncrypt new GZIPInputStream(responseStream): responseStream, encoding); <br>responseStream.close() <br> //リターン コードが 30130 2303307 の場合これは、ページがリダイレクトされたことを意味し、その場所の URL を再リクエストします。これは、Cookie を取得するために一部のログイン認証が使用される場合に重要です。それ以外の場合、(HttpStatus.SC_MOVED_PERMANENTLY == ステータス <br>|| HttpStatus.SC_MOVED_TEMPORARILY = = ステータス <br>|| HttpStatus .SC_SEE_OTHER == ステータス <br>|| HttpStatus.SC_TEMPORARY_REDIRECT == ステータス) <br>{ <br> //新しい URL アドレスを読み取ります <br>Header = requestMethod.getResponseHeader("position"); ) <br>{ <br>String redirectUrl = header.getValue(); <br>if (null = redirectUrl! <br>&& false == redirectUrl.isEmpty()) <br>{ <br>responseContent = void <br>if (null == redirectUrl || redirectUrl.isEmpty; ()) <br>{ <br> redirectUrl = "/"; <br>} <br><br> if (false == redirectUrl.startsWith("http://") <br>! && empty = website) <br>{ <br> if (website.startsWith( "/ ")) <br>{ <br> redirectUrl = website + redirectUrl; <br>} <br> other <br>{ <br> redirectUrl = website + "/" + redirectUrl; <br>} <br>} <br><br>GetMethod リダイレクト = 新しい実装 getMethod( redirectUrl); <br>ヘッダリファラー = requestMethod .getRequestHeader("リファラー"); <br>if (null = リファラー! ; + } <br><br>} //ターミナル <br><br>} //終了ステータス <br><br>} の追いつき (例外 5) <br>{ <br>e.printStackTrace() <br>}最後に <br>{ <br>;If (requestMethod! = NULL) <br>{ <br>requestMethod.releaseConnection(); <br>} <br>} <br>ReturnContent; <br>} <br><br>/ ** <br>* 指定されたエンコーディングに従ってストリームから情報を読み取る <br>* <br>* @parameter inStream <br>*パラメータエンコーディング<br>* @return <br>*IOExceptionをスローします <br>* / <br>パブリック静的文字列getContentByStream(InputStream inStream, Stringエンコーディング)はIOExceptionをスローします <br>{ <br>if (null == Break) <br>{ <br> return NULL <br>} <br><br>StringBuilder content = new StringBuilder(); <br>//指定されたエンコード形式を使用してストリーム コンテンツを読み取ります <br>BufferedReader (new InputStreamReader(Interstitial, encoding)); <br>String message = NULL; .readLine())!) <br>{ <br>content.append(message); <br>content.append("r n") <br>} <br>// リーダーを閉じ、リソースを解放します <br>reader.close(); toString()); <br>} <br><br>/ ** <br>*PostMethod から継承された内部クラス。郵便リクエストのエンコード形式を指定するために使用されます <br>* / <br>EncodePostMethod によって拡張されたパブリック静的クラス PostMethod <br>{ <br> プライベート文字列エンコーディング = NULL; <br> public EncodePostMethod(URL String, String encode) <br>{ <br> super(URL); <br>this.encode = encode; <br>} <br><br>@override <br> public String getRequestCharSet() <br>{ <br> // TODO メソッド スタブを自動的に生成します <br> return ( this.encode); <br>} <br><br>} <br><br>/ ** <br>* テスト <br>* <br>* @parameter ARGS <br>* / <br> public static valid main(String[] args) <br>{ <br>//System.setProperty("http .proxyHost", "165.228.128.10"); <br>//System.setProperty("http.proxyPort", "3128"); <br> //System.setProperty("http.proxySet","true"); <br><br><br> String reqUrl = " http://news.39.net/jbyw/index.html "; <br>reqUrl = " http:// news.39.net/a/2010722/1404231.html ”; <br>Map<String, String> ; ヘッダー = 新しい HashMap <String, String>(); <br>headers.put("エンコーディングを受け入れる" , "gzip,deflate"); <br><br>HttpClient = getHttpClient();ヘッダー、null、"GBK"); <br>System.out.println(htmlContent);</string></string></string></p> </div> </div> <div class="wzconShengming_sp"> <div class="bzsmdiv_sp">このウェブサイトの声明</div> <div>この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。</div> </div> </div> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="2507867629"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div class="AI_ToolDetails_main4sR"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5902227090019525" data-ad-slot="3653428331" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <!-- <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>人気の記事</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780570.html" title="R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780641.html" title="R.E.P.O.最高のグラフィック設定" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.最高のグラフィック設定</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796785841.html" title="アサシンのクリードシャドウズ:シーシェルリドルソリューション" class="phpgenera_Details_mainR4_bottom_title">アサシンのクリードシャドウズ:シーシェルリドルソリューション</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780520.html" title="R.E.P.O.誰も聞こえない場合はオーディオを修正する方法" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.誰も聞こえない場合はオーディオを修正する方法</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796779766.html" title="WWE 2K25:Myriseのすべてのロックを解除する方法" class="phpgenera_Details_mainR4_bottom_title">WWE 2K25:Myriseのすべてのロックを解除する方法</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/article.html">もっと見る</a> </div> </div> </div> --> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>ホットAIツール</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title"> <h3>Undresser.AI Undress</h3> </a> <p>リアルなヌード写真を作成する AI 搭載アプリ</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title"> <h3>AI Clothes Remover</h3> </a> <p>写真から衣服を削除するオンライン AI ツール。</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title"> <h3>Undress AI Tool</h3> </a> <p>脱衣画像を無料で</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title"> <h3>Clothoff.io</h3> </a> <p>AI衣類リムーバー</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173405034393877.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Hentai Generator" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/ai/ai-hentai-generator" title="AI Hentai Generator" class="phpmain_tab2_mids_title"> <h3>AI Hentai Generator</h3> </a> <p>AIヘンタイを無料で生成します。</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/ai">もっと見る</a> </div> </div> </div> <script src="https://sw.php.cn/hezuo/cac1399ab368127f9b113b14eb3316d0.js" type="text/javascript"></script> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>人気の記事</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780570.html" title="R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.説明されたエネルギー結晶と彼らが何をするか(黄色のクリスタル)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780641.html" title="R.E.P.O.最高のグラフィック設定" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.最高のグラフィック設定</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796785841.html" title="アサシンのクリードシャドウズ:シーシェルリドルソリューション" class="phpgenera_Details_mainR4_bottom_title">アサシンのクリードシャドウズ:シーシェルリドルソリューション</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796780520.html" title="R.E.P.O.誰も聞こえない場合はオーディオを修正する方法" class="phpgenera_Details_mainR4_bottom_title">R.E.P.O.誰も聞こえない場合はオーディオを修正する方法</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/1796779766.html" title="WWE 2K25:Myriseのすべてのロックを解除する方法" class="phpgenera_Details_mainR4_bottom_title">WWE 2K25:Myriseのすべてのロックを解除する方法</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/article.html">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>ホットツール</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/92" title="メモ帳++7.3.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="メモ帳++7.3.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/92" title="メモ帳++7.3.1" class="phpmain_tab2_mids_title"> <h3>メモ帳++7.3.1</h3> </a> <p>使いやすく無料のコードエディター</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/93" title="SublimeText3 中国語版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 中国語版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/93" title="SublimeText3 中国語版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 中国語版</h3> </a> <p>中国語版、とても使いやすい</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/121" title="ゼンドスタジオ 13.0.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="ゼンドスタジオ 13.0.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/121" title="ゼンドスタジオ 13.0.1" class="phpmain_tab2_mids_title"> <h3>ゼンドスタジオ 13.0.1</h3> </a> <p>強力な PHP 統合開発環境</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/469" title="ドリームウィーバー CS6" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="ドリームウィーバー CS6" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/469" title="ドリームウィーバー CS6" class="phpmain_tab2_mids_title"> <h3>ドリームウィーバー CS6</h3> </a> <p>ビジュアル Web 開発ツール</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/ja/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/ja/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Mac版</h3> </a> <p>神レベルのコード編集ソフト(SublimeText3)</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/ai">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>ホットトピック</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/gmailyxdlrkzn" title="Gmailメールのログイン入り口はどこですか?" class="phpgenera_Details_mainR4_bottom_title">Gmailメールのログイン入り口はどこですか?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>7461</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>15</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/cakephp-tutor" title="CakePHP チュートリアル" class="phpgenera_Details_mainR4_bottom_title">CakePHP チュートリアル</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1376</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>52</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/steamdzhmcssmgs" title="Steamのアカウント名の形式は何ですか" class="phpgenera_Details_mainR4_bottom_title">Steamのアカウント名の形式は何ですか</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>77</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>11</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/winactivationkeyper" title="Win11 Activation Key Permanent" class="phpgenera_Details_mainR4_bottom_title">Win11 Activation Key Permanent</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>44</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>19</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/ja/faq/newyorktimesdailybrief" title="NYTの接続はヒントと回答です" class="phpgenera_Details_mainR4_bottom_title">NYTの接続はヒントと回答です</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>17</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>17</span> </div> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/ja/faq/zt">もっと見る</a> </div> </div> </div> </div> </div> <div class="Article_Details_main2"> <div class="phpgenera_Details_mainL4"> <div class="phpmain1_2_top"> <a href="javascript:void(0);" class="phpmain1_2_top_title">Related knowledge<img src="/static/imghw/index2_title2.png" alt="" /></a> </div> <div class="phpgenera_Details_mainL4_info"> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/771323.html" title="PHP フレームワークのパフォーマンス比較: 速度と効率の究極の対決" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/887/227/171445122761296.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP フレームワークのパフォーマンス比較: 速度と効率の究極の対決" /> </a> <a href="https://www.php.cn/ja/faq/771323.html" title="PHP フレームワークのパフォーマンス比較: 速度と効率の究極の対決" class="phphistorical_Version2_mids_title">PHP フレームワークのパフォーマンス比較: 速度と効率の究極の対決</a> <span class="Articlelist_txts_time">Apr 30, 2024 pm 12:27 PM</span> <p class="Articlelist_txts_p">ベンチマークによると、Laravel はページの読み込み速度とデータベース クエリで優れており、CodeIgniter はデータ処理で優れています。 PHP フレームワークを選択するときは、アプリケーションのサイズ、トラフィック パターン、開発チームのスキルを考慮する必要があります。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/782482.html" title="Java 同時プログラミングで同時実行テストとデバッグを実行するにはどうすればよいですか?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/465/014/171521838610584.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Java 同時プログラミングで同時実行テストとデバッグを実行するにはどうすればよいですか?" /> </a> <a href="https://www.php.cn/ja/faq/782482.html" title="Java 同時プログラミングで同時実行テストとデバッグを実行するにはどうすればよいですか?" class="phphistorical_Version2_mids_title">Java 同時プログラミングで同時実行テストとデバッグを実行するにはどうすればよいですか?</a> <span class="Articlelist_txts_time">May 09, 2024 am 09:33 AM</span> <p class="Articlelist_txts_p">同時実行テストとデバッグ Java 同時プログラミングにおける同時実行テストとデバッグは非常に重要であり、次の手法が利用可能です。 同時実行テスト: 単体テスト: 単一の同時タスクを分離してテストします。統合テスト: 複数の同時タスク間の相互作用をテストします。負荷テスト: 高負荷時のアプリケーションのパフォーマンスとスケーラビリティを評価します。同時実行デバッグ: ブレークポイント: スレッドの実行を一時停止し、変数を検査するかコードを実行します。ロギング: スレッドのイベントとステータスを記録します。スタック トレース: 例外のソースを特定します。視覚化ツール: スレッドのアクティビティとリソースの使用状況を監視します。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/782412.html" title="58 ポートレート プラットフォームの構築におけるアルゴリズムの適用" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/887/227/171521647523028.png?x-oss-process=image/resize,m_fill,h_207,w_330" alt="58 ポートレート プラットフォームの構築におけるアルゴリズムの適用" /> </a> <a href="https://www.php.cn/ja/faq/782412.html" title="58 ポートレート プラットフォームの構築におけるアルゴリズムの適用" class="phphistorical_Version2_mids_title">58 ポートレート プラットフォームの構築におけるアルゴリズムの適用</a> <span class="Articlelist_txts_time">May 09, 2024 am 09:01 AM</span> <p class="Articlelist_txts_p">1. 58 Portraits プラットフォーム構築の背景 まず、58 Portraits プラットフォーム構築の背景についてお話ししたいと思います。 1. 従来のプロファイリング プラットフォームの従来の考え方ではもはや十分ではありません。ユーザー プロファイリング プラットフォームを構築するには、複数のビジネス分野からのデータを統合して、ユーザーの行動や関心を理解するためのデータ マイニングも必要です。最後に、ユーザー プロファイル データを効率的に保存、クエリ、共有し、プロファイル サービスを提供するためのデータ プラットフォーム機能も必要です。自社構築のビジネス プロファイリング プラットフォームとミドルオフィス プロファイリング プラットフォームの主な違いは、自社構築のプロファイリング プラットフォームは単一のビジネス ラインにサービスを提供し、オンデマンドでカスタマイズできることです。ミッドオフィス プラットフォームは複数のビジネス ラインにサービスを提供し、複雑な機能を備えていることです。モデリングを提供し、より一般的な機能を提供します。 2.58 中間プラットフォームのポートレート構築の背景のユーザーのポートレート 58</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/777136.html" title="Eclipseにサーバーを追加する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202405/05/2024050519273996127.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Eclipseにサーバーを追加する方法" /> </a> <a href="https://www.php.cn/ja/faq/777136.html" title="Eclipseにサーバーを追加する方法" class="phphistorical_Version2_mids_title">Eclipseにサーバーを追加する方法</a> <span class="Articlelist_txts_time">May 05, 2024 pm 07:27 PM</span> <p class="Articlelist_txts_p">Eclipse にサーバーを追加するには、次の手順に従います。 サーバー ランタイム環境の作成 サーバーの構成 サーバー インスタンスの作成 サーバー ランタイム環境の選択 サーバー インスタンスの構成 サーバー デプロイメント プロジェクトの開始</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/771860.html" title="回避モジュールは、アプリケーション層の DOS 攻撃から Web サイトを保護します。" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/887/227/171446966663630.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="回避モジュールは、アプリケーション層の DOS 攻撃から Web サイトを保護します。" /> </a> <a href="https://www.php.cn/ja/faq/771860.html" title="回避モジュールは、アプリケーション層の DOS 攻撃から Web サイトを保護します。" class="phphistorical_Version2_mids_title">回避モジュールは、アプリケーション層の DOS 攻撃から Web サイトを保護します。</a> <span class="Articlelist_txts_time">Apr 30, 2024 pm 05:34 PM</span> <p class="Articlelist_txts_p">Web サイトをオフラインにする攻撃方法はさまざまですが、より複雑な方法にはデータベースやプログラミングの技術的知識が必要です。より単純な方法は、「DenialOfService」(DOS) 攻撃と呼ばれます。この攻撃手法の名前は、一般の顧客や Web サイト訪問者からの通常のサービス要求を拒否させるという目的に由来しています。一般に、DOS 攻撃には 2 つの形式があります。OSI モデルの 3 番目と 4 番目の層、つまりネットワーク層の攻撃です。OSI モデルの 7 番目の層、つまり、アプリケーション層の攻撃です。攻撃 - ネットワーク層は、大量のジャンク トラフィックが Web サーバーに流れるときに発生します。スパム トラフィックがネットワークの処理能力を超えると、Web サイトがダウンします。 2 番目のタイプの DOS 攻撃はアプリケーション層で行われ、組み合わせて使用​​されます。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/774933.html" title="PHP を使用して Web サイトを展開および維持する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/000/164/171469764982686.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP を使用して Web サイトを展開および維持する方法" /> </a> <a href="https://www.php.cn/ja/faq/774933.html" title="PHP を使用して Web サイトを展開および維持する方法" class="phphistorical_Version2_mids_title">PHP を使用して Web サイトを展開および維持する方法</a> <span class="Articlelist_txts_time">May 03, 2024 am 08:54 AM</span> <p class="Articlelist_txts_p">PHP Web サイトを正常に展開して維持するには、次の手順を実行する必要があります。 Web サーバー (Apache や Nginx など) を選択する PHP をインストールする データベースを作成して PHP に接続する コードをサーバーにアップロードする ドメイン名と DNS を設定する Web サイトのメンテナンスを監視する手順には、PHP および Web サーバーの更新、Web サイトのバックアップ、エラー ログの監視、コンテンツの更新が含まれます。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/778251.html" title="Kubernetes Operator を活用して PHP クラウド展開を簡素化するにはどうすればよいですか?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/465/014/171498546880049.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="Kubernetes Operator を活用して PHP クラウド展開を簡素化するにはどうすればよいですか?" /> </a> <a href="https://www.php.cn/ja/faq/778251.html" title="Kubernetes Operator を活用して PHP クラウド展開を簡素化するにはどうすればよいですか?" class="phphistorical_Version2_mids_title">Kubernetes Operator を活用して PHP クラウド展開を簡素化するにはどうすればよいですか?</a> <span class="Articlelist_txts_time">May 06, 2024 pm 04:51 PM</span> <p class="Articlelist_txts_p">KubernetesOperator は、次の手順に従って PHP クラウド デプロイメントを簡素化します。 PHPOperator をインストールして、Kubernetes クラスターと対話します。 PHP アプリケーションをデプロイし、イメージとポートを宣言します。ログの取得、記述、表示などのコマンドを使用してアプリケーションを管理します。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/ja/faq/776832.html" title="PHP セキュリティのベスト プラクティスを実装する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/000/465/014/171487747138914.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="PHP セキュリティのベスト プラクティスを実装する方法" /> </a> <a href="https://www.php.cn/ja/faq/776832.html" title="PHP セキュリティのベスト プラクティスを実装する方法" class="phphistorical_Version2_mids_title">PHP セキュリティのベスト プラクティスを実装する方法</a> <span class="Articlelist_txts_time">May 05, 2024 am 10:51 AM</span> <p class="Articlelist_txts_p">PHP セキュリティのベスト プラクティスを実装する方法 PHP は、動的でインタラクティブな Web サイトの作成に使用される最も人気のあるバックエンド Web プログラミング言語の 1 つです。ただし、PHP コードはさまざまなセキュリティ脆弱性に対して脆弱になる可能性があります。 Web アプリケーションをこれらの脅威から保護するには、セキュリティのベスト プラクティスを実装することが重要です。入力検証 入力検証は、ユーザー入力を検証し、SQL インジェクションなどの悪意のある入力を防止するための重要な最初のステップです。 PHP は、filter_var() や preg_match() などのさまざまな入力検証関数を提供します。例: $username=filter_var($_POST['username'],FILTER_SANIT</p> </div> </div> <a href="https://www.php.cn/ja/be/" class="phpgenera_Details_mainL4_botton"> <span>See all articles</span> <img src="/static/imghw/down_right.png" alt="" /> </a> </div> </div> </div> </main> <footer> <div class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!</p> </div> <div class="footermid"> <a href="https://www.php.cn/ja/about/us.html">私たちについて</a> <a href="https://www.php.cn/ja/about/disclaimer.html">免責事項</a> <a href="https://www.php.cn/ja/update/article_0_1.html">Sitemap</a> </div> <div class="footerbottom"> <p> © php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <script src="/static/js/common_new.js"></script> <script type="text/javascript" src="/static/js/jquery.cookie.js?1744357176"></script> <script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' /> <script type='text/javascript' src='/static/js/viewer.min.js?1'></script> <script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function () { var u = "https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u + 'matomo.php']); _paq.push(['setSiteId', '9']); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s); })(); </script> <script> // top layui.use(function () { var util = layui.util; util.fixbar({ on: { mouseenter: function (type) { layer.tips(type, this, { tips: 4, fixed: true, }); }, mouseleave: function (type) { layer.closeAll("tips"); }, }, }); }); document.addEventListener("DOMContentLoaded", (event) => { // 定义一个函数来处理滚动链接的点击事件 function setupScrollLink(scrollLinkId, targetElementId) { const scrollLink = document.getElementById(scrollLinkId); const targetElement = document.getElementById(targetElementId); if (scrollLink && targetElement) { scrollLink.addEventListener("click", (e) => { e.preventDefault(); // 阻止默认链接行为 targetElement.scrollIntoView({ behavior: "smooth" }); // 平滑滚动到目标元素 }); } else { console.warn( `Either scroll link with ID '${scrollLinkId}' or target element with ID '${targetElementId}' not found.` ); } } // 使用该函数设置多个滚动链接 setupScrollLink("Article_Details_main1L2s_1", "article_main_title1"); setupScrollLink("Article_Details_main1L2s_2", "article_main_title2"); setupScrollLink("Article_Details_main1L2s_3", "article_main_title3"); setupScrollLink("Article_Details_main1L2s_4", "article_main_title4"); setupScrollLink("Article_Details_main1L2s_5", "article_main_title5"); setupScrollLink("Article_Details_main1L2s_6", "article_main_title6"); // 可以继续添加更多的滚动链接设置 }); window.addEventListener("scroll", function () { var fixedElement = document.getElementById("Article_Details_main1Lmain"); var scrollTop = window.scrollY || document.documentElement.scrollTop; // 兼容不同浏览器 var clientHeight = window.innerHeight || document.documentElement.clientHeight; // 视口高度 var scrollHeight = document.documentElement.scrollHeight; // 页面总高度 // 计算距离底部的距离 var distanceToBottom = scrollHeight - scrollTop - clientHeight; // 当距离底部小于或等于300px时,取消固定定位 if (distanceToBottom <= 980) { fixedElement.classList.remove("Article_Details_main1Lmain"); fixedElement.classList.add("Article_Details_main1Lmain_relative"); } else { // 否则,保持固定定位 fixedElement.classList.remove("Article_Details_main1Lmain_relative"); fixedElement.classList.add("Article_Details_main1Lmain"); } }); </script> </body> </html>