スクレイピングをしようとしたのですが、文字化けが発生しスクレイピングすることができません。
どのようにコードを書けば文字化けを防ぐことができるでしょうか?
写真の部分を抜き出したい!
python
1url="https://quizlet.com/jp/513582655/%E3%82%B3%E3%83%B3%E7%89%A9-flash-cards/"
python
1 html= requests.get(url) 2 html.encoding = "utf-8" 3 soup = BeautifulSoup(html.text, "html.parser")
soupの実行結果
pytohn
1<!DOCTYPE html> 2 3<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> 4<head> 5<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> 6<title> 7 Captcha Challenge… 8 </title> 9<style type="text/css">@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(data:application/octet-stream;charset=binary;base64,d09GRgABAAAAADe0AA8AAAAAXkwAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABHREVGAAABWAAAABYAAAAWABAA3UdQT1MAAAFwAAAADAAAAAwAFQAKR1NVQgAAAXwAAABZAAAAdN3O3ptPUy8yAAAB2AAAAF8AAABgoT6eyWNtYXAAAAI4AAAAmAAAAMyvDbOdZ2FzcAAAAtAAAAAQAAAAEAAVACNnbHlmAAAC4AAAJFkAADPsEH7ynmhlYWQAACc8AAAANgAAADb/4BA9aGhlYQAAJ3QAAAAeAAAAJA63BP1obXR4AAAnlAAAAggAAANstMtZiGtlcm4AACmcAAAKFwAAHpCj66TjbG9jYQAAM7QAAAGpAAABvEPuT9ltYXhwAAA1YAAAACAAAAAgAmQBqW5hbWUAADWAAAAArAAAATIU3C9KcG9zdAAANiwAAAGGAAACKJgOahEAAQAAAAwAAAAAAAAAAgABAAAA3AABAAAAAQAAAAoACgAKAAB4AR3HNcJBAQDA8d+rLzDatEXOrqDd4S2ayUX1beTyDwEyyrqCbXrY+xPD8ylAsF0tUn/4nlj89Z9A7+tETl5RXdNNZGDm+vXYXWjgLDRzEhoLBAYv0/0NHAAAAHgxfAUCtWrHjOvl9yY0OGAQzHjx/vtODAGVrQ2VDDnCMBZSqUEv2vXbu2H5+5r6+vUSwWd2ipc/bs2ToAxMGDB/NY0eCfFhQUMJUZTIDbt29fs9eVuKqiy93im4LUK+f+a3xszHI7OzsJ3gPVAS+vPoboYUMVs2dOr960YW3liaMHK69ePPPqRsa16tystKpbudcrigtyqqGSXsqMUshlNjx+Byu6eaMSj8m7kVaZk5lanZuVioqEgwf/58QVxcHG8fr30dFxfXLy4uLjouLm5FXFzcdjNbHhcXNyguLu5fcXFxn31Mnwv2xZkzZz5ugOCNN95ax/gPgTfeeOMBgjfeeOMBgjfeeOMBgjfeeOMBgjfeeOtQ+3/GdjwlIs5MTAAAAABJRU5ErkJggg==);background-repeat:no-repeat;background-size:264px 261px;float:right;height:261px;width:264px;padding-bottom:-100px}</style> 10<script type="text/javascript"> 11//<![CDATA[ 12window.onload=function(){var e=document.body.innerHTML.match(/Error reference number: (\d+)/),t=e&&2===e.length?e[1]:"???";if("1013"===t){var n="querySelector"in document&&document.querySelector(".quizlet-area");if(n){var o=document.createElement("h1");o.innerHTML="How do I fix the problem?",n.appendChild(o);var r=document.createElement("p");r.innerHTML='<a href="https://docs.google.com/document/d/1m4aTN0uRQrIsX4jgLpq2RiOz8LcLn68PQfS_tIRXXFM/" class="how-to-fix-1013">Click here for instructions.</a>',n.appendChild(r);var c="querySelector"in document&&document.querySelector(".quizlet-area .send-feedback");c&&c.setAttribute("style","display: none")}}var a=document.body.innerHTML.match(/CloudFlare Location: ([^<]+)/),i=a&&2===a.length?a[1]:"???",l="querySelector"in document&&document.querySelector(".cf-error-details");if(l)var d=l.innerHTML.match(/<h1>([^<]+)</h1>/),u=d&&2===d.length?d[1]:"???";else var u="";var m=new XMLHttpRequest,s=["type=basic_security","page="+encodeURIComponent(location.href),"http_status="+t,"cloudflare_dc="+i,"error_title="+u,"user_agent="+encodeURIComponent(navigator.userAgent)].join("&");m.open("GET",location.protocol+"//external.quizlet.com/?"+s,!0),m.send()}; 13//]]> 14</script> 15<script type="text/javascript"> 16 //<![CDATA[ 17 (function(){ 18 window._cf_chl_opt={ 19 cvId: "2", 20 cType: "interactive", 21 cNounce: "32969", 22 cRay: "66e29671ecd20a66", 23 cHash: "00f715d8b43f73d", 24 cFPWv: "g", 25 cTTimeMs: "4000", 26 cLt: "n", 27 cRq: { 28 ru: "aHR0cHM6Ly9xdWl6bGV0LmNvbS9qcC80OTc2ODY1MTQvJUUzJTgyJUI3JUUzJTgyJUI5JUUzJTgyJUJGJUUzJTgzJUIzLWZsYXNoLWNhcmRzLw==", 29 ra: "cHl0aG9uLXJlcXVlc3RzLzIuMjUuMQ==", 30 rm: "R0VU", 31 d: "htDvVGGUdYpCSOxXwHRWBMWVorDDLTmWCyQ1vCkbZssnoK7ls65mgH7NU75F7mq5JIZzh6zdSUWXJmXtYRSwRNbSfQQIIv+SKoa1ExBydYeha12q6wRH86RMxoKdydMhfbeJHnOEbTXkZD4HYjbnDO4jF1lcPaGD9Mc5/cAeqncMU9ZqM=", 32 t: "MTYyNjE4MDEwOS4xMTcwMDA=", 33 m: "a3o8euA5/9bLqvtM15IpJLuxjN2MMKLw02NHr0k9NYU=", 34 i1: "icCT00gHRrkHdkts1XEGpQ==", 35 i2: "qDecD1ALDI+3IFs9rJGlPg==", 36 zh: "4Kj6XmF0hGGMZJNWCgjIRT2xfrTX/uiLLeGtRlIykWA=", 37 uh: "5GU+jYv2xJ+bCaE/ARmi/DORbiS/v56CW7E0TH4XWQk=", 38 hh: "nTP4dbBwJvmIUutjybAVUa7fWq61RCea/XXAvATwsNM=", 39 } 40 }; 41 }()); 42 //]]> 43 </script> 44</head> 45<body> 46<div id="wrap"> 47<div class="quizlet-area"> 48<h1>One more step…</h1> 49<p>The security system for this website has been triggered. Completing the challenge below proves you are a human and gives you temporary access.</p> 50</div> 51<div class="cloudflare-area"> 52<form action="/jp/497686514/%E3%82%B7%E3%82%B9%E3%82%BF%E3%83%B3-flash-cards/?__cf_chl_captcha_tk__=24d3eb0aa1e39a7ed44a0c9ce988b7926ce033dd-1626180109-0-AWOoYuEQ4AcaWjdC4PRUSI1xDumHKmSuFD0r0nNdMixe4u3k9tyNta3uRFz_0QyjcseKm8H10ujST8kJMijoN3AAHfmpYh4dG_EkA5ByXXZDMFWNkg6uFp786rm2RARE8rx3f784HzVagrJaXmfYOGkVidiugW7tZaLdhk42g8xPc5FLISoJuKYFgjEG1ivMUYaNTsg5RC6ukTTK-XKgaEkMKIOJLkG4ud10kFyqrrMSz_r9x4Wo1hY4Fcq4han9Jezd4W2AfUoyVLVfrQRv6O-KmgflKme2j2r2Gbam0RQ9QgB2T3R0BePZ_A0AFIpeEUYj8vqLQbarZRHQQRM_gFx_2nXpmbS_rCDpF0u-7OqrCzIGESTCIrfBnoXuFm03rnrGV_qzijdj2-HLJL9UBAi1d1MIY6jmsztguLsex8jUIK_kEPXQK1vV-LZk0zDuq8VfVtLb_VvA-jkEZwkYTjdUp9qHM7FjogDCSDcwcBQIUoOk4jUD0VWNRuD8dwqz7A91VKDp9aDMhQyR3C-EH9MRIAcIdX0uji7e262jAvHDluSatLuy8sOThd93Rf6o8_pSloVJ3n9hjex2tBiN-vVG8XJcg74XQTRcGC5MEA94NIM01H9lbF_9XNVng9V-GdOUqNKzDhdZLJuG8e_SH1_XtBqBpy8YUysMAT7HBzaITz7HUlKI_jnwbYIRgMidNvQ4q4zfdXyEDKch4dSg2VhD1ub0wBlED5J6AyyBGS2JvYIn1GHBiN5CsMzOcr1B1w" class="challenge-form interactive-form" enctype="application/x-www-form-urlencoded" id="challenge-form" method="POST"> 53<div id="cf-please-wait"> 54<div id="spinner"> 55<div id="cf-bubbles"> 56<div class="bubbles"></div> 57<div class="bubbles"></div> 58<div class="bubbles"></div> 59</div> 60</div> 61<p data-translate="please_wait" id="cf-spinner-please-wait">Please stand by, while we are checking your browser...</p> 62<p data-translate="redirecting" id="cf-spinner-redirecting" style="display:none">Redirecting...</p> 63</div> 64<input name="r" type="hidden" value="a856a7f09583d98cec4b4479a7801e2b6540ab14-1626180109-0-ASRqKg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ECy0ZnobqN2FhAUA3JKmocYGjcfQoC05gdvZVQxzpV19GGeC/tmHkUTmw1emhDWdI3woMoqe+lXF1kEu5mkxJUZXxMuCex54Mr5hE8026+4AiwwhKtMH/N2irj0yL+g3XZgrE2NGbDQoSnoh5nUnr+YrGYG8ig7BxFqHKdbg9NsjXHlZNDhkbCXCXhkYKb95zLHXOpnbbcmzbXV4BQUXgYc487r5YG1tD7QM5ZYMmU1pQtUwSY51H+Hza12emCiMDzQ5x7cdUFeg7vWaQygtPsQtrmj6b0lakSa7vrm4OvuggmEmCKATmOByYWr0hVlP1jcv7LLOV0KmiIT+ZUKl7vaWOtfo+aGVnoC5HS/GbUVXl9qscVdbl3IQNYdVf36zKjJ/dYW0Mxxfz9RZxN5rgVxZSbWB6RzXry/n7PTZOy6SK5ALNxlcX/vsHd0GNNwLVM5Ucd7a3sT6VeVFwF+wqxuwPeig7CL7tDwIHKZ1k7lwY4wNyn6td/thB9BD1liF0Xm3FN1dXX31fAwNn48nBOXJnL5kehcTCC63WhnTgUcnmPc55LAdOR/YLl9pyib7FbVHXbqZt6BprK4bQCiQ+UBMy3hQYab9CPq1eNDII0LIigCKlo9aGNBuqkPhziPQLvboKD8c5lcBQK89P74KdJ1WQR5L4kmNoEGJ4aO9rRiFEFNmjoKAAMJxzTMELEtjvJH0Na/1FQd9GyEr5nAR1q2n3Fjum3fn60="/> 65<input name="cf_captcha_kind" type="hidden" value="h"/> 66<input name="vc" type="hidden" value="c3cfa19b252eb22b101b0fb8d3624bb7"/> 67<noscript class="cf-captcha-info" id="cf-captcha-bookmark"> 68<h1 data-translate="turn_on_js" style="color:#bd2426;">Please turn JavaScript on and reload the page.</h1> 69</noscript> 70<div class="cookie-warning" data-translate="turn_on_cookies" id="no-cookie-warning" style="display:none"> 71<p data-translate="turn_on_cookies" style="color:#bd2426;">Please enable Cookies and reload the page.</p> 72</div> 73<script type="text/javascript"> 74 //<![CDATA[ 75 var a = function() {try{return !!window.addEventListener} catch(e) {return !1} }, 76 b = function(b, c) {a() ? document.addEventListener("DOMContentLoaded", b, c) : document.attachEvent("onreadystatechange", b)}; 77 b(function(){ 78 var cookiesEnabled=(navigator.cookieEnabled)? true : false; 79 if(!cookiesEnabled){ 80 var q = document.getElementById('no-cookie-warning');q.style.display = 'block'; 81 } 82 }); 83 //]]> 84 </script> 85<div id="trk_captcha_js" style="background-image:url('/cdn-cgi/images/trace/captcha/nojs/h/transparent.gif?ray=66e29671ecd20a66')"></div> 86</form> 87<script type="text/javascript"> 88 //<![CDATA[ 89 (function(){ 90 var isIE = /(MSIE|Trident/|Edge/)/i.test(window.navigator.userAgent); 91 var trkjs = isIE ? new Image() : document.createElement('img'); 92 trkjs.setAttribute("src", "/cdn-cgi/images/trace/captcha/js/transparent.gif?ray=66e29671ecd20a66"); 93 trkjs.id = "trk_captcha_js"; 94 trkjs.setAttribute("alt", ""); 95 document.body.appendChild(trkjs); 96 var cpo=document.createElement('script'); 97 cpo.type='text/javascript'; 98 cpo.src="/cdn-cgi/challenge-platform/h/g/orchestrate/captcha/v1?ray=66e29671ecd20a66"; 99 document.getElementsByTagName('head')[0].appendChild(cpo); 100 }()); 101 //]]> 102 </script> 103</div> 104</div> 105</body> 106</html>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/07/13 13:46
2021/07/13 13:59
2021/07/13 14:33
2021/07/13 14:42