PHP 中用curl访问一个页面和直接在浏览器中直接访问这个页面为什么两次的返回值不一样?






Csdn user default icon
php curl - 通过浏览器响应访问url:通过curl响应访问url:401?

<div class="post-text" itemprop="text"> <p>I have a url which contains all information in the url (username/password/content ect)</p> <p>If i visit the url in my browser I get a successful response.</p> <p>However If I visit the url through curl I get 401.</p> <p>There is no authentication on the url.</p> <p>What could be causing this?</p> <p><strong>Code:</strong></p> <pre><code>$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, ';pass=pass&amp;msgclass=test&amp;msgid=6&amp;body=Some+Content&amp;to=02712345678'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $mconnect[$index]['app_name'] . ":" . $mconnect[$index]['app_pass']); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.12 (KHTML, like Gecko) Chrome/9.0.587.0 Safari/534.12'); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CURLOPT_POST, false); if(curl_exec($ch) === false) echo 'fail: '.curl_error($ch); </code></pre> <p></p><hr> <strong>Update...Strange...</strong><br> <p>So,</p> <p>I am building my url through $mconnect[$index]['url'] . '?' . http_build_query($url);</p> <p>which gives me the above url.</p> <p>So,</p> <p>If I have </p> <pre><code>$url = $mconnect[$index]['url'] . '?' . http_build_query($url); curl_setopt($ch, CURLOPT_URL, $url); </code></pre> <p>I get the 401.</p> <p>But,</p> <p>If I then do <code>echo $mconnect[$index]['url'] . '?' . http_build_query($url);</code></p> <p>I get </p> <blockquote> <p><a href=";pass=pass&amp;msgclass=test&amp;msgid=6&amp;body=Some+Content&amp;to=02712345678" rel="nofollow">;pass=pass&amp;msgclass=test&amp;msgid=6&amp;body=Some+Content&amp;to=02712345678</a></p> </blockquote> <p>so if I then do </p> <pre><code>$url = ';pass=pass&amp;msgclass=test&amp;msgid=6&amp;body=Some+Content&amp;to=02712345678'; curl_setopt($ch, CURLOPT_URL, $url); </code></pre> <p>Then it works...</p> <p>any ideas?</p> </div>

PHP Curl在浏览器中返回不同的URL结果

<div class="post-text" itemprop="text"> <p>I am using PHP Curl with this code:</p> <pre><code>curl_setopt($ch, CURLOPT_URL, ''); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); //curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0"); $uagent = 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Firefox/22.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/36.0.1985.125 Chrome/36.0.1985.125 Safari/537.36'; curl_setopt($ch, CURLOPT_USERAGENT, $uagent); curl_setopt($ch, CURLOPT_REFERER, ''); curl_setopt($ch, CURLOPT_AUTOREFERER, true); </code></pre> <p>My question is.. why PHP Curl gives different result Than Searching URL in BROWSER?</p> <p>PHP Curls gives a big BODY CONTENT... with this LINE... In Spanish... "No encontramos resultados para tu búsqueda..." In English.....There are no results for your search...</p> <p>What happen with this URL? How Can I CURL and read by code this URL and get the REAL RESULTS AS BROWSER?</p> <p>Help me please! Thanks!!!</p> </div>


<div class="post-text" itemprop="text"> <p>I have a curl like this:</p> <pre><code> $t1 = time(); exec('echo $t1 &gt;&gt; debug'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $service); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $output = curl_exec($ch); curl_close($ch); $t2 = time(); exec('echo $t2 &gt;&gt; debug'); </code></pre> <p>when i execute the url in browser it is fast enough. but this curl is much slower(about 20 seconds later). how can i make it as fast as the simple request?</p> <p>also i have these results when i get the curl_getinfo:</p> <pre><code> connect_time: 0.01 //on average total_time: 0.24 //on average </code></pre> </div>

访问Prestashop webservice,PHP Curl获得401 Unauthorized访问权限,但可以在浏览器中使用

<div class="post-text" itemprop="text"> <p>I am using PrestaShopWebservice library to access Prestashiop 1.7 Webservice, I always <code>get 401 Unauthorized</code> but it is accessible in browser.</p> <p>I have already tried adding:</p> <pre><code>SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </code></pre> <p>in <code>.htaccess</code><br> also tried concatenating <code>&amp;ws_key="token"</code></p> <p>but nothing works</p> <pre><code> $url = 'http://someurl/api/'; $token = 'mytoken'; try { $webService = new \PrestaShopWebservice($url, $token, true); $xml = $webService-&gt;get(['resource'=&gt;'products']); var_dump($xml); } catch (\PrestaShopWebserviceException $ex) { echo 'Other error: &lt;br /&gt;' . $ex-&gt;getMessage(); } </code></pre> </div>

PHP cURL通过浏览器下载文件

<div class="post-text" itemprop="text"> <p>Im create script to download file from some file server but not work perfectly.</p> <pre><code> function downloadPage2($url){ $ch = curl_init(); $userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'; curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, false); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_BUFFERSIZE, 8096); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $buffer) { header('Expires: 0'); // no cache header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Cache-Control: private', false); header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="mp3.mp3"'); header('Content-Transfer-Encoding: binary'); // header('Content-Length: ' . strlen($buffer)); // provide file size header('Connection: close'); echo $buffer; return strlen($buffer); }); curl_exec ($ch); curl_close($ch); } </code></pre> <p>And when type $url to file (mp3) from server its download this file but not right filesize. Example: File on server has size 4.5mb and my script downloaded it but size is 6mb. Music is playing but interrupts per second. Do you know where is a problem?</p> <p>I tried set content-lenght in header but every function return content lengh = 0</p> </div>


<?php set_time_limit(0); error_reporting(1024); ob_start(); header("Content-Type:text/html;charset=GBK"); header('Cache-Control:no-cache,must-revalidate'); header('Pragma:no-cache'); ini_set('date.timezone','Asia/Shanghai'); $url = '[]=hhad&poolcode[]=had'; $content = getCurlData($url); var_dump($content); function getCurlData($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "", "Cache-Control: max-age=0", "Accept-Encoding: gzip, deflate", "Accept:*/*", "Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3", "Connection: keep-alive", "Cookie:COLLCK=3282378182; Hm_lvt_860f3361e3ed9c994816101d37900758=1505871680; COLLCK=4081554587; Hm_lpvt_860f3361e3ed9c994816101d37900758=1505889209", "Upgrade-Insecure-Requests: 1", )); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.04'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,TRUE); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_MAXREDIRS,20); $cdata = curl_exec($ch); $info = curl_getinfo($ch); print_r($info); /* if($info['http_code']==302){ getCurlData($url); } */ curl_close($ch); return $cdata; } ob_end_flush(); exit; ?>

如何在浏览器中显示cURL进度条(使用PHP exec()函数)

<div class="post-text" itemprop="text"> <p>I'm using this tiny PHP code in order to mirror any files into my server.</p> <pre><code>&lt;?php $cmd= "curl -L -O"; exec($cmd); ?&gt; </code></pre> <p>But the browser is freezing until the mirroring process gets finished. My question is that how can I display the progress bar like when I run this command in Terminal. something like this:</p> <pre><code>% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed </code></pre> <p>I tried many flags such as:</p> <pre><code>-v --verbose -I -include --trace - </code></pre> <p>but none of them worked. I also asked a question <a href="">here</a> to convert it to a PHP CURL code but no one could help me with that!</p> <p>If it's not possible, it's really appreciated advising me to do the same job by any other commands.</p> </div>

cURL GET方法在php中失败,但浏览器和控制台成功完成

<div class="post-text" itemprop="text"> <p>I apologize if the title is inappropriate, but I kind of could not think of a better definition for it.</p> <p>I am going nuts over this problem. I have been working on collecting feeds and data via cURL for the past 5+ years and have never encountered this kind of situation. I have a large json to collect over the GET method from a remote server via HTTPS from address that looks something like this <a href=";someParam=1" rel="nofollow noreferrer">;someParam=1</a></p> <p>someParam is changeable, and for some values with lower amount of data everything works fine, almost identical speeds to browser, but in several cases cURL always goes to tiomeout set, while in browser and from console everything works fine</p> <p><strong>PHP</strong></p> <p>My cURL is as follows:</p> <pre><code>$ch = curl_init(); $url = ';someParam=1'; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); // I've added this user agent as it is the same as the one Chrome uses curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36'); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); // I have tried removing the SSL part below, but no difference curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, "HIGH:!SSLv3s"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // tried this with true, but no difference curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 1200); // what ever the timeout I set the cURL always goes to timeout curl_setopt($ch, CURLOPT_VERBOSE, true); $response = curl_exec($ch); if (curl_errno($ch)) { print("cURL error: " . curl_error($ch)); print_r(curl_getinfo($ch)); } else { print_r(json_decode($response)); } curl_close($ch); </code></pre> <p>This is the verbose output:</p> <pre><code>* Hostname was NOT found in DNS cache * Trying 12.34.567.89... * Connected to (12.34.567.89) port 443 (#0) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSL connection using ECDHE-RSA-AES256-SHA384 * Server certificate: * subject: OU=Domain Control Validated; CN=* * start date: 2016-03-03 09:41:38 GMT * expire date: 2018-03-04 09:52:18 GMT * subjectAltName: matched * issuer: C=US; ST=Arizona; L=Scottsdale; O=Starfield Technologies, Inc.; OU=; CN=Starfield Secure Certificate Authority - G2 * SSL certificate verify ok. &gt; GET /thisDotNetEndPoint?token=bla-bla-trutj&amp;someParam=1 HTTP/1.1 User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36 Host: Accept: */* */ * Operation timed out after 1200001 milliseconds with 0 bytes received * Closing connection 0 </code></pre> <p>It always goes to timout whatever the timout I set, tried even setting it to 2 hours.</p> <p>I've even tried adding these but no difference:</p> <pre><code>curl_setopt($ch, CURLOPT_NOSIGNAL, 1); curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1); curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, 1200); </code></pre> <p><strong>Browser</strong></p> <p>When I enter the same url in browser the response comes back in 6-9 minutes</p> <p><strong>cURL from console</strong></p> <p>I have used the simplest command and it works in same time as browser:</p> <pre><code>$ curl -X GET -v ';someParam=1' </code></pre> <p>Verbose output:</p> <pre><code>* Hostname was NOT found in DNS cache * Trying 12.34.567.89... * Connected to (12.34.567.89) port 443 (#0) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1): * SSLv3, TLS handshake, Server hello (2): * SSLv3, TLS handshake, CERT (11): * SSLv3, TLS handshake, Server key exchange (12): * SSLv3, TLS handshake, Server finished (14): * SSLv3, TLS handshake, Client key exchange (16): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSLv3, TLS change cipher, Client hello (1): * SSLv3, TLS handshake, Finished (20): * SSL connection using ECDHE-RSA-AES256-SHA384 * Server certificate: * subject: OU=Domain Control Validated; CN=* * start date: 2016-03-03 09:41:38 GMT * expire date: 2018-03-04 09:52:18 GMT * subjectAltName: matched * issuer: C=US; ST=Arizona; L=Scottsdale; O=Starfield Technologies, Inc.; OU=; CN=Starfield Secure Certificate Authority - G2 * SSL certificate verify ok. &gt; GET /thisDotNetEndPoint?token=bla-bla-trutj&amp;someParam=1 HTTP/1.1 &gt; User-Agent: curl/7.35.0 &gt; Host: &gt; Accept: */* */ &gt; &lt; HTTP/1.1 200 OK &lt; Cache-Control: private &lt; Content-Type: application/json; charset=utf-8 &lt; Server: Microsoft-IIS/8.5 &lt; X-StackifyID: V1|b8b10c35-2649-4f67-ba6a-b5ad15ef553b|C56050|CD18| &lt; Set-Cookie: .ASPXANONYMOUS=looI88UVBp6Cg5tLkzVejO4CNRilhyKjMY4hFqhuO48vdVT19U8h5oisC9khFv1rOmH6Ii_lEec-9XhipEvh1UkewhufqfmlTGFsyQCaML06NVa-5-Vr_OikZb07R6pdHCeRtn9liBVJfamJmXiElA2; expires=Thu, 02-Feb-2017 20:54:18 GMT; path=/; HttpOnly &lt; X-AspNetMvc-Version: 5.2 &lt; Rx-CID: ae9907d6fc394b24b6599e74ab5a668f &lt; Rx_RequestId: f3fff82c4de04bba90b2bbc5704ac787 &lt; X-Powered-By: ASP.NET &lt; Strict-Transport-Security: max-age=31536000 &lt; Access-Control-Allow-Origin: * &lt; Access-Control-Allow-Headers: rx-cid &lt; Date: Fri, 25 Nov 2016 10:25:00 GMT &lt; Content-Length: 2231472 &lt; [and the response is printed here] </code></pre> <p>Any ideas?</p> <p>Thanks in advance.</p> </div>


我采集一个网站,该站直接访问无需登录,但是我采集到的页面却是登录页面,用curl采集的,看了下getinfo,有跳转,再跟踪跳转链接,再次跳转到了登录页面。 我用curl模拟了下浏览器,但是没用!之前遇到也有防采集的,但是模拟一下就可以了,这个实在搞不定了! 请教一下有没有办法采集到!


** *a.php:* ** echo date('h:i:s') . "\n"; sleep(10); echo date('h:i:s') . "\n"; ** *b.php:* ** phpinfo(); ================= 环境: nginx + php-cgi ================= 如果我直接访问b.php,会立即显示出phpinfo的那些信息. 如果我直接访问a.php,会等待10秒钟显示出信息. 如果我先访问a.php,同时在另外一个标签访问b.php,为什么两个页面都要等待10秒钟才能一起显示? php菜鸟在此谢谢...


1、haproxy.conf global chroot /root/gaproxy/haproxy/var/chroot daemon user haproxy group haproxy log local0 warning pidfile /root/gaproxy/haproxy/var/run/ maxconn 20000 spread-checks 3 nbproc 1 defaults log global mode http retries 3 option redispatch contimeout 5000 clitimeout 50000 srvtimeout 50000 listen oldboytest bind *:80 mode http stats enable stats hide-version stats uri /admin?status stats auth admin:oldboy123 balance roundrobin option httpclose option forwardfor cookie SERVERID insert indirect timeout server 15s timeout connect 15s server web1 cookie A weight 1 check port 80 inter 5000 fall 5 server web2 cookie B weight 2 check port 80 inter 5000 fall 5 2、用curl访问看是否轮询: 命令: for((i=0;i<10;i++));do curl;sleep 2;done 结果:oldboy2 zhangfei zhangfei oldboy2 zhangfei zhangfei oldboy2 zhangfei zhangfei oldboy2 也实现的轮询 2、现在换成浏览器是否实现轮询: 用IE: ![图片说明]( 点刷新一直都只访问一个问题,不会换成另外一个页面 用世界之窗:![图片说明]( 也是一样,点刷新不会轮询。 问题: 我想问下,是不是我哪里配置错了,但是curl为什么又能轮询。


<div class="post-text" itemprop="text"> <p>I'm working with drupal 7 and REST api. I'd like to log in into drupal with curl and later when i visit the website with a browser i want to be logged in.</p> <p>i'm usin gthis code:</p> <pre><code>&lt;?php $user_data = array( 'username' =&gt; 'usertest', 'password' =&gt; 'pass', ); $ch = curl_init(); $tmpfname = dirname(__FILE__).'/'.$_COOKIE['PHPSESSID'].'.txt'; curl_setopt($ch, CURLOPT_URL, ""); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $user_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt( $ch, CURLOPT_COOKIESESSION, true ); curl_setopt( $ch, CURLOPT_COOKIEJAR, $tmpfname ); curl_setopt( $ch, CURLOPT_COOKIEFILE, $tmpfname ); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); ?&gt; </code></pre> <p>And it works pretty well, it logs the user in, but when i visit "" i'm not logget in as "usertest". Is there any way to log me into Drupal and allow me to access with a browser?</p> <p>The goal is to log me in into many website with the same users when i log in into one as i wrote here (<a href="">Same webserver, same drupal, same db, single sign on?</a>).</p> </div>


php怎么限制只有一个域名能访问特定页面,curl伪造也能判断的出来么 或者liunx能限制也可以。或者nginx, 求一个能实习的


比如QQ音乐,地址举例: 可以通过浏览器直接打开下载。 但通过程序就无法下载,curl也不行。 只能下载到一个表示没有权限的页面。 我试过模拟浏览器的header信息也不行。 不知道在模拟header的情况下,程序请求和浏览器请求到底有何不同? 有没有高手可以使用程序下载到这个文件?使用php最佳。 望不吝赐教。 解决了,就是对cookie有校验。


<div class="post-text" itemprop="text"> <p>First of all, the purpose of this is to spider one of our signed-in applications and get data about jobs run which I may not be able to get any other way.</p> <p>I can log in via a browser, and also can inspect my cookies; how would I then take that (in a timely manner) and add that information to a cURL call so that I can use PHP to parse the return page (and links)? </p> </div>


<div class="post-text" itemprop="text"> <p>I've got an almost empty page that I need for a curl. The thing is that it is also accessible by a browser and looks weird.</p> <p>Is it possible in PHP to detect if the request come from a browser or a curl ? So that way I can make a redirect if it comes from browser.</p> <p>Thank you.</p> </div>

Revel App可在浏览器中访问,通过curl进入终端时返回502

<div class="post-text" itemprop="text"> <p>The Revel site I'm working on works fine in the browser, but when hit it in the terminal via a curl, it returns a 502. Checking the error log for Revel, it throws a long panic error when hit by curl, starting like...</p> <blockquote> <p>{"caller":"panic.go:35","error":"runtime error: index out of range","lvl":"eror","module":"revel","msg":"PanicFilter: Caught panic, unable to determine stack location","section":"util","stack":"goroutine 265...</p> </blockquote> <p>When I access the site via the browser, no new error appears. Nginx is throwing the following error...</p> <blockquote> <p>22393#22393: *5098 upstream prematurely closed connection while reading response header from upstream</p> </blockquote> <p>My nginx config looks essentially like...</p> <pre><code>server { server_name; location / { proxy_pass http://localhost:9000; } } </code></pre> <p>At first I thought this was an issue with my Nginx config, but seeing I'm getting an error thrown by Go/Revel when I hit the site via curl request, I'm wondering if it's an issue with Go or Revel? Anyone had similar issues when getting a Go site running through Nginx? Thanks in advance, any direction would be useful.</p> </div>

【PHP求助】通过PHP Curl模拟浏览器远程抓取内容

需要抓取的内容:页面做了限制; 如图所示: ![图片说明](


如题, 服务器端返回json串,每次都这样, t":"\u81ea\u7531\u5e7f\u573a\u5* transfer closed with at least 3714 bytes remaining * Closing connection #0 curl: (18) transfer closed with at least 3714 bytes remaining 1b63d2c.jpg","user到这里就截止了 但是用百度浏览器,却可以正常显示整个json串 各位大神帮帮忙


大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...


今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...



技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...


“亚马逊丛林里的蝴蝶扇动几下翅膀就可能引起两周后美国德州的一次飓风……” 这句人人皆知的话最初用来描述非线性系统中微小参数的变化所引起的系统极大变化。 而在更长的时间尺度内,我们所生活的这个世界就是这样一个异常复杂的非线性系统…… 水泥、穹顶、透视——关于时间与技艺的蝴蝶效应 公元前3000年,古埃及人将尼罗河中挖出的泥浆与纳特龙盐湖中的矿物盐混合,再掺入煅烧石灰石制成的石灰,由此得来了人...


loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...






提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...






私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...




场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...


不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...






当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...


HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...



你打算用Java 8一辈子都不打算升级到Java 14,真香



编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?





已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...



《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)


一文带你入门Java Stream流,太强了

两个星期以前,就有读者强烈要求我写一篇 Java Stream 流的文章,我说市面上不是已经有很多了吗,结果你猜他怎么说:“就想看你写的啊!”你看你看,多么苍白的喜欢啊。那就“勉为其难”写一篇吧,嘻嘻。 单从“Stream”这个单词上来看,它似乎和 包下的 InputStream 和 OutputStream 有些关系。实际上呢,没毛关系。Java 8 新增的 Stream 是为...