鱼C论坛

 找回密码
 立即注册
查看: 987|回复: 7

爬虫无法爬取到需要的内容

[复制链接]
发表于 2023-6-13 10:37:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x

求助:用BeautifulSoup抓出来页面的text怎么显示这个?和右键“检查”出来的东西完全不一样,无法爬区到需要的内容,是什么地方出了问题?




<!DOCTYPE html><html><head><meta charset=utf-8><!--[if lte IE 8]>
      <script type="text/javascript">
        setTimeout(function(){
          window.location.href="./ie.html"
        }, 1000)
      </script>
    <![endif]--><meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1"><meta name=viewport content="initial-scale=1,user-scalable=yes,minimum-scale=0.2,maximum-scale=5"><link rel=icon href=https://static.tpass.chinatax.gov.cn/favicon.ico><link rel=stylesheet href=https://static.tpass.chinatax.gov.cn/qrcode/index.css><title></title><link href=https://static.tpass.chinatax.gov.cn/static/css/app.360f40c5.css rel=preload as=style><link href=https://static.tpass.chinatax.gov.cn/static/css/chunk-elementUI.1194f7cb.css rel=preload as=style><link href=https://static.tpass.chinatax.gov.cn/static/css/chunk-libs.3dfb7769.css
rel=preload as=style><link href=https://static.tpass.chinatax.gov.cn/static/js/app.045809b5.js rel=preload as=script><link href=https://static.tpass.chinatax.gov.cn/static/js/chunk-elementUI.e8a89fa6.js rel=preload as=script><link href=https://static.tpass.chinatax.gov.cn/static/js/chunk-libs.2f45a243.js rel=preload as=script><link href=https://static.tpass.chinatax.gov.cn/static/css/chunk-elementUI.1194f7cb.css rel=stylesheet><link href=https://static.tpass.chinatax.gov.cn/static/css/chunk-libs.3dfb7769.css rel=stylesheet><link href=https://static.tpass.chinatax.gov.cn/static/css/app.360f40c5.css rel=stylesheet></head><body><noscript><strong>We're sorry but doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script>(function(c){function n(n){for(var u,a,f=n[0],d=n[1],b=n[2],t=0,r=[];t<f.length;t++)a=f[t],Object.prototype.hasOwnProperty.call(h,a)&&h[a]&&r.push(h[a][0]),h[a]=0;for(u in d)Object.prototype.hasOwnProperty.call(d,u)&&(c[u]=d[u]);o&&o(n);while(r.length)r.shift()();return k.push.apply(k,b||[]),e()}function e(){for(var c,n=0;n<k.length;n++){for(var e=k[n],u=!0,a=1;a<e.length;a++){var f=e[a];0!==h[f]&&(u=!1)}u&&(k.splice(n--,1),c=d(d.s=e[0]))}return c}var u={},a={runtime:0},h={runtime:0},k=[];function f(c){return d.p+"static/js/"+({"chunk-commons":"chunk-commons"}[c]||c)+"."+{"chunk-014cc97c":"ec6e3f05","chunk-04a4fc4b":"bdb3b066","chunk-06a77285":"0bcd4c63","chunk-06b22b1f":"44954e72","chunk-070b1a11":"79028c1f","chunk-096c25e9":"7593afe7","chunk-0a002f9c":"7e3bd737","chunk-0af43fe4":"0b83f5b2","chunk-0f24d8cf":"210a5666","chunk-0f3bf3c3":"0b098c62","chunk-116d9336":"2c28eb2c","chunk-11f6338a":"8553f1e0","chunk-1310eb16":"c37bbfc4","chunk-7ac796b5":"b77632fc","chunk-14c345f8":"a7814f59","chunk-18eb1d6c":"36643178","chunk-1c2a7c1e":"7647af03","chunk-1d44426f":"d6c0315a","chunk-1f584e93":"fd1ce3bf","chunk-1fa2d0ea":"b655d27d","chunk-207dcc2e":"11f65d3c","chunk-21732346":"a3e7d02d","chunk-251c0e20":"a210c585","chunk-25608f60":"a93ac032","chunk-28ab6908":"6625e23a","chunk-2d0d63a1":"95042921","chunk-2d207f36":"a83caa7f","chunk-2d3b262f":"dfce43c9","chunk-2d93251a":"97afa8ad","chunk-3568f13e":"edfe4e2d","chunk-30f80890":"33e04c31","chunk-3340cbca":"b9764568","chunk-35825a8c":"02fc74e9","chunk-36ba3d77":"355575aa","chunk-3be78d39":"a201df2f","chunk-3df1aa30":"aa5a3ec8","chunk-3e6e2374":"1d54c811","chunk-41c617a9":"db5dacd5","chunk-38daf637":"3f3502a6","chunk-617c3008":"dd8e6952","chunk-435fc092":"f6241ac9","chunk-4af9add4":"0b356123","chunk-499db220":"85e63775","chunk-4a3baf5d":"76f62d9f","chunk-6fd409dc":"9bda520d","chunk-55836112":"06664720","chunk-56b43110":"0c547b77","chunk-5ab88692":"5fd1f89a","chunk-5d5f6e58":"904344e0","chunk-5d64eaca":"d0944db3","chunk-612eb8f1":"f4c70cd4","chunk-613490da":"630bb495","chunk-6315ad59":"c00027bc","chunk-6cd400ac":"316f79ba","chunk-37e853cb":"a5d63a1d","chunk-6ea5c580":"8f48e026","chunk-7337d659":"89c5ecd4","chunk-7347cc24":"78effb75","chunk-7441dcaa":"5692e700","chunk-76e72766":"afe7adb0","chunk-7aa287be":"86f46245","chunk-7c4ba3d3":"1f4b3ac2","chunk-8f680dac":"5dcabda5","chunk-94758b62":"accf8a8a","chunk-aabf2db8":"ae166e1e","chunk-b2be82f2":"27f51b5b","chunk-bc069938":"42bc1831","chunk-bf8c30fe":"cb7c8c86","chunk-c04062e6":"6b5b510e","chunk-cc63f0de":"e36ff2bc","chunk-commons":"efcf97e3","chunk-03c90e64":"bf3234d2","chunk-6ecfe440":"2e29380b","chunk-7877a184":"ed3b2673","chunk-363dfc4e":"d3784d74","chunk-7915c20e":"5aa93191","chunk-3a8bdaf2":"4215fafb","chunk-3b10690a":"7a9710a7","chunk-3b9af68b":"5e0ec387","chunk-4e327866":"92c46049","chunk-6e99aac8":"bf7fbaa2","chunk-d721b60c":"17823bcc","chunk-db9514fe":"2a5cd45c","chunk-c8f95f18":"b3f79f2b","chunk-67120de0":"dc7ee00f","chunk-b0907e56":"e3f3e6e0","chunk-3e1f1012":"3a49de9b","chunk-31d26246":"c4b4ef55","chunk-bd159d10":"29bfb7ef","chunk-27881b24":"5fe7c1b8","chunk-98670d66":"40e3b336","chunk-2dc2c2e4":"c12d769e","chunk-d2bad170":"f41070bc","chunk-d4eefc7a":"95822f65","chunk-d8063262":"17da2aae","chunk-dd434d5e":"19ab62f2","chunk-f9b1eaaa":"3bcde1dd","chunk-fad40d92":"a1aff1b6"}[c]+".js"}function d(n){if(u[n])return u[n].exports;var e=u[n]={i:n,l:!1,exports:{}};return c[n].call(e.exports,e,e.exports,d),e.l=!0,e.exports}d.e=function(c){var n=[],e={"chunk-014cc97c":1,"chunk-04a4fc4b":1,"chunk-06a77285":1,"chunk-06b22b1f":1,"chunk-070b1a11":1,"chunk-096c25e9":1,"chunk-0a002f9c":1,"chunk-0af43fe4":1,"chunk-0f24d8cf":1,"chunk-0f3bf3c3":1,"chunk-116d9336":1,"chunk-11f6338a":1,"chunk-1310eb16":1,"chunk-7ac796b5":1,"chunk-14c345f8":1,"chunk-18eb1d6c":1,"chunk-1c2a7c1e":1,"chunk-1d44426f":1,"chunk-1f584e93":1,"chunk-1fa2d0ea":1,"chunk-207dcc2e":1,"chunk-21732346":1,"chunk-251c0e20":1,"chunk-25608f60":1,"chunk-28ab6908":1,"chunk-2d3b262f":1,"chunk-2d93251a":1,"chunk-3568f13e":1,"chunk-30f80890":1,"chunk-3340cbca":1,"chunk-35825a8c":1,"chunk-36ba3d77":1,"chunk-3be78d39":1,"chunk-3df1aa30":1,"chunk-3e6e2374":1,"chunk-38daf637":1,"chunk-617c3008":1,"chunk-435fc092":1,"chunk-4af9add4":1,"chunk-499db220":1,"chunk-4a3baf5d":1,"chunk-6fd409dc":1,"chunk-55836112":1,"chunk-56b43110":1,"chunk-5ab88692":1,"chunk-5d5f6e58":1,"chunk-5d64eaca":1,"chunk-612eb8f1":1,"chunk-613490da":1,"chunk-6315ad59":1,"chunk-6cd400ac":1,"chunk-37e853cb":1,"chunk-6ea5c580":1,"chunk-7337d659":1,"chunk-7347cc24":1,"chunk-7441dcaa":1,"chunk-76e72766":1,"chunk-7aa287be":1,"chunk-7c4ba3d3":1,"chunk-8f680dac":1,"chunk-94758b62":1,"chunk-aabf2db8":1,"chunk-b2be82f2":1,"chunk-bc069938":1,"chunk-bf8c30fe":1,"chunk-c04062e6":1,"chunk-cc63f0de":1,"chunk-commons":1,"chunk-03c90e64":1,"chunk-6ecfe440":1,"chunk-7877a184":1,"chunk-363dfc4e":1,"chunk-7915c20e":1,"chunk-3a8bdaf2":1,"chunk-3b10690a":1,"chunk-3b9af68b":1,"chunk-4e327866":1,"chunk-6e99aac8":1,"chunk-d721b60c":1,"chunk-db9514fe":1,"chunk-c8f95f18":1,"chunk-b0907e56":1,"chunk-3e1f1012":1,"chunk-31d26246":1,"chunk-bd159d10":1,"chunk-27881b24":1,"chunk-98670d66":1,"chunk-2dc2c2e4":1,"chunk-d2bad170":1,"chunk-d4eefc7a":1,"chunk-d8063262":1,"chunk-dd434d5e":1,"chunk-f9b1eaaa":1,"chunk-fad40d92":1};a[c]?n.push(a[c]):0!==a[c]&&e[c]&&n.push(a[c]=new Promise((function(n,e){for(var u="static/css/"+({"chunk-commons":"chunk-commons"}[c]||c)+"."+{"chunk-014cc97c":"e5bcf2c5","chunk-04a4fc4b":"9dd2284b","chunk-06a77285":"9797d2c1","chunk-06b22b1f":"a8317352","chunk-070b1a11":"38e85429","chunk-096c25e9":"13955699","chunk-0a002f9c":"bf297d7d","chunk-0af43fe4":"b442224a","chunk-0f24d8cf":"d4d9a086","chunk-0f3bf3c3":"cf0d428c","chunk-116d9336":"b4f7874c","chunk-11f6338a":"11277192","chunk-1310eb16":"e2f82efc","chunk-7ac796b5":"11325eeb","chunk-14c345f8":"0ad0487e","chunk-18eb1d6c":"762cf733","chunk-1c2a7c1e":"c61cf29d","chunk-1d44426f":"ebe7fbde","chunk-1f584e93":"b5a90f8c","chunk-1fa2d0ea":"ca49eae5","chunk-207dcc2e":"bf6bb034","chunk-21732346":"231c542a","chunk-251c0e20":"ee2937a5","chunk-25608f60":"cadc03d9","chunk-28ab6908":"d358125b","chunk-2d0d63a1":"31d6cfe0","chunk-2d207f36":"31d6cfe0","chunk-2d3b262f":"3a155b2d","chunk-2d93251a":"18383ffa","chunk-3568f13e":"8cfe16dc","chunk-30f80890":"0ea113d0","chunk-3340cbca":"a3f1f422","chunk-35825a8c":"76056eea","chunk-36ba3d77":"22762663","chunk-3be78d39":"052188f4","chunk-3df1aa30":"840b2146","chunk-3e6e2374":"e7afab56","chunk-41c617a9":"31d6cfe0","chunk-38daf637":"cff057e4","chunk-617c3008":"31ba7414","chunk-435fc092":"cb1532ac","chunk-4af9add4":"60a3afb0","chunk-499db220":"b06f83bc","chunk-4a3baf5d":"b7821389","chunk-6fd409dc":"59916a83","chunk-55836112":"de6b5001","chunk-56b43110":"edcef508","chunk-5ab88692":"40b03f29","chunk-5d5f6e58":"e897a395","chunk-5d64eaca":"eba2697b","chunk-612eb8f1":"785894fb","chunk-613490da":"f27a771d","chunk-6315ad59":"6902a372","chunk-6cd400ac":"d7465adc","chunk-37e853cb":"2b8a7f42","chunk-6ea5c580":"d3d91ee6","chunk-7337d659":"9d4a635b","chunk-7347cc24":"10047479","chunk-7441dcaa":"70a299fd","chunk-76e72766":"d9c627bf","chunk-7aa287be":"6b2516ea","chunk-7c4ba3d3":"fc79e23f","chunk-8f680dac":"0e5c1735","chunk-94758b62":"3325aa9c","chunk-aabf2db8":"ed6925b2","chunk-b2be82f2":"09f9cccf","chunk-bc069938":"49d170d0","chunk-bf8c30fe":"0bffdb64","chunk-c04062e6":"b3eedb90","chunk-cc63f0de":"5e433619","chunk-commons":"f5e8959b","chunk-03c90e64":"26ac93bb","chunk-6ecfe440":"4806b757","chunk-7877a184":"6cbe16c4","chunk-363dfc4e":"22fb61fe","chunk-7915c20e":"b6247efd","chunk-3a8bdaf2":"e7dae78f","chunk-3b10690a":"1261cc9b","chunk-3b9af68b":"4b106dd0","chunk-4e327866":"397a81e1","chunk-6e99aac8":"4933e350","chunk-d721b60c":"6ec15679","chunk-db9514fe":"235c4aec","chunk-c8f95f18":"f978ecc0","chunk-67120de0":"31d6cfe0","chunk-b0907e56":"59281a69","chunk-3e1f1012":"100c8ccd","chunk-31d26246":"b4c6624f","chunk-bd159d10":"efd7050f","chunk-27881b24":"a7cd9a8e","chunk-98670d66":"a7849676","chunk-2dc2c2e4":"9b6b82df","chunk-d2bad170":"88ab61b8","chunk-d4eefc7a":"e7ebaaca","chunk-d8063262":"29a0edf6","chunk-dd434d5e":"a186990c","chunk-f9b1eaaa":"2895aea5","chunk-fad40d92":"c2f01880"}[c]+".css",h=d.p+u,k=document.getElementsByTagName("link"),f=0;f<k.length;f++){var b=k[f],t=b.getAttribute("data-href")||b.getAttribute("href");if("stylesheet"===b.rel&&(t===u||t===h))return n()}var r=document.getElementsByTagName("style");for(f=0;f<r.length;f++){b=r[f],t=b.getAttribute("data-href");if(t===u||t===h)return n()}var o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.onload=n,o.onerror=function(n){var u=n&&n.target&&n.target.src||h,k=new Error("Loading CSS chunk "+c+" failed.\n("+u+")");k.code="CSS_CHUNK_LOAD_FAILED",k.request=u,delete a[c],o.parentNode.removeChild(o),e(k)},o.href=h;var i=document.getElementsByTagName("head")[0];i.appendChild(o)})).then((function(){a[c]=0})));var u=h[c];if(0!==u)if(u)n.push(u[2]);else{var k=new Promise((function(n,e){u=h[c]=[n,e]}));n.push(u[2]=k);var b,t=document.createElement("script");t.charset="utf-8",t.timeout=120,d.nc&&t.setAttribute("nonce",d.nc),t.src=f(c);var r=new Error;b=function(n){t.onerror=t.onload=null,clearTimeout(o);var e=h[c];if(0!==e){if(e){var u=n&&("load"===n.type?"missing":n.type),a=n&&n.target&&n.target.src;r.message="Loading chunk "+c+" failed.\n("+u+": "+a+")",r.name="ChunkLoadError",r.type=u,r.request=a,e[1](r)}h[c]=void 0}};var o=setTimeout((function(){b({type:"timeout",target:t})}),12e4);t.onerror=t.onload=b,document.head.appendChild(t)}return Promise.all(n)},d.m=c,d.c=u,d.d=function(c,n,e){d.o(c,n)||Object.defineProperty(c,n,{enumerable:!0,get:e})},d.r=function(c){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(c,"__esModule",{value:!0})},d.t=function(c,n){if(1&n&&(c=d(c)),8&n)return c;if(4&n&&"object"===typeof c&&c&&c.__esModule)return c;var e=Object.create(null);if(d.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:c}),2&n&&"string"!=typeof c)for(var u in c)d.d(e,u,function(n){return c[n]}.bind(null,u));return e},d.n=function(c){var n=c&&c.__esModule?function(){return c["default"]}:function(){return c};return d.d(n,"a",n),n},d.o=function(c,n){return Object.prototype.hasOwnProperty.call(c,n)},d.p="https://static.tpass.chinatax.gov.cn/",d.oe=function(c){throw console.error(c),c};var b=window["webpackJsonp"]=window["webpackJsonp"]||[],t=b.push.bind(b);b.push=n,b=b.slice();for(var r=0;r<b.length;r++)n(b[r]);var o=t;e()})([]);</script><script src=https://static.tpass.chinatax.gov.cn/static/js/chunk-elementUI.e8a89fa6.js></script><script src=https://static.tpass.chinatax.gov.cn/static/js/chunk-libs.2f45a243.js></script><script src=https://static.tpass.chinatax.gov.cn/static/js/app.045809b5.js></script></body><script src=https://static.tpass.chinatax.gov.cn/qrcode/qrcode.min.js></script><script src=https://static.tpass.chinatax.gov.cn/qrcode/fzKeyboard.js></script><script src=https://static.tpass.chinatax.gov.cn/qrcode/bundle.js></script></html>




爬虫.jpg
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2023-6-13 10:38:15 | 显示全部楼层
"chunk-*******",这是什么东西?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-6-13 10:41:14 | 显示全部楼层
你的代码呢?还有你要爬什么内容?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-6-13 11:00:38 | 显示全部楼层
代码很简单:

print处理来的东西乱七八糟的,这是税务局的网站,是不是js加过密了?

    re=requests.get(user_list)
    re.encoding='utf-8'

    print(re.text)
    soup=bs(re.text,'lxml')

    inf=soup.find_all('div',class_='cell el-tooltip')
    print(len(inf))
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-6-13 11:32:43 | 显示全部楼层
元素的html都是经过浏览器渲染后得到的,要看网络面板的html代码;当然这两者绝大多数情况下是一模一样的,你这个估计就是两者不同造成的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-6-13 13:42:58 | 显示全部楼层
Brucey 发表于 2023-6-13 11:32
元素的html都是经过浏览器渲染后得到的,要看网络面板的html代码;当然这两者绝大多数情况下是一模一样的, ...

爬虫好像爬不到我想要的内容,有什么办法解决吗?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2023-6-13 15:11:21 | 显示全部楼层
xialinren 发表于 2023-6-13 11:00
代码很简单:

print处理来的东西乱七八糟的,这是税务局的网站,是不是js加过密了?

这个div都搜不到的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2023-6-14 09:32:57 | 显示全部楼层
大神们帮忙看看,有没有解决办法和思路。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-26 22:01

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表