程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

How difficult are the 10k+ interview questions? Python takes you to collect and find out~

編輯:Python

Catalog ( You can click on the place you want to see )

      • This code is provided by : Qingdeng Education - Si Yue
  • Third party libraries required :
  • development environment :
    • If installed python Third-party module :
    • How to configure pycharm Inside python Interpreter ?
    • pycharm How to install plug-ins ?
  • Code
      • One 、 The import module
      • Two 、 Add camouflage
      • 3、 ... and 、 Send a request
      • Four 、 get data
      • 5、 ... and 、 Parsing data
  • Tail language


This code is provided by : Qingdeng Education - Si Yue


Third party libraries required :

  • requests >>> pip install requests
  • parsel >>> pip install parsel

development environment :

  • edition Ben : python 3.8
  • Editor : pycharm 2021.2

If installed python Third-party module :

  1. win + R Input cmd Click ok , Enter the installation command pip install Module name (pip install requests) enter
  2. stay pycharm Click on the Terminal( terminal ) Enter the installation command

How to configure pycharm Inside python Interpreter ?

  1. choice file( file ) >>> setting( Set up ) >>> Project( project ) >>> python interpreter(python Interpreter )
  2. Click on the gear , choice add
  3. add to python The installation path

pycharm How to install plug-ins ?

  1. choice file( file ) >>> setting( Set up ) >>> Plugins( plug-in unit )
  2. Click on Marketplace Enter the name of the plug-in you want to install such as : Translation plug-ins Input translation / Chinese plug-in Input Chinese
  3. Select the corresponding plug-in and click install( install ) that will do
  4. After successful installation Yes, it will pop up restart pycharm The option to Click ok , Restart to take effect

Code

Due to the audit mechanism , I deleted some things from the website , Xiao Kenai can add it by themselves , It's easy

If there is a little lazy or not able to change, Xiao Kenai can also confide in me , I sent you ~

One 、 The import module

# Python There are a lot of third-party tools 
# There are also many built-in tools
import requests # Send a request Third-party module
import parsel # Parsing data Third-party module

Two 、 Add camouflage

# camouflage Python Dictionary container
headers = {

# User information
'cookie': 'TAUnique=%1%enc%3AHARC1EMLan58P07MI4ZMcqI%2BzHGWuLGBt6TE6zQDNwk%3D; TASSK=enc%3AAL%2Bm9xwFy7%2BjYONIRS%2F2kEbA%2FtOrlDbcW%2FwCSHs44XP9R3ddE%2BKJxi3FiDuozLe0Ov2ujtnFah8i0sN%2FRdUxZGis0TClwsaz7%2B7Uv8dh%2BvHM%2FfH9C%2FcEYLBYBtn1yLmBNg%3D%3D; _lc2_fpi=b140173de591--01fxvvhm5q52dte42gshbn1234; __gads=ID=887c76ae8964a5bc:T=1646981079:S=ALNI_MYwTZNsJPdidCGF3BTM3pOV79wAUg; TADCID=1dW7BfvYitWbqfH6ABQCFdpBzzOuRA-9xvCxaMyI1247i3OJBq9qNVWvXr3O78hI1lbd1kQngmuzyADlwihJyk7Y0wRjaf58AtM; PAC=AN2PxgmiZ1GRIiU_4c0KpV6mA_btSrKwqVybwoo_d5lgw6zXj_ZRZjSJBwH84o9UVTmeAgNhfd51gzwBlQcgcKT1VFPbzjf_j4wqU-2ufAxdlELGL3F1zacCWByaKOXRvixlLn4OXM42wYZ_VBHqSpVYj7ST_l8sbYSeYnXyqk0D1fTKvJaddWGzHbBAlKHZ2H5I_u-nk6oDQ9BooTrGu-lfGWRQfA0yVhJ1jXpar4dvw3Jw2M0hgdP0MnX1GhSkt_7ddkbOm4oPgbBlDwQ4iJrY6ZtWR0F1dQ_BvzH6z0ppsUXSC-KMe61YA3ZX0ZMJ9p2s3mGMo3ecdJCt44MxAQi_7Jqzg4myLdYV6kjlaix1; ServerPool=B; PMC=V2*MS.22*MD.20220616*LD.20220617; TASID=023207A6A44049DBBF0ACA838F764F72; ak_bmsc=894F53FCE8B8FB7782AE15FEFA7E8955~000000000000000000000000000000~YAAQyDUduAriZHGBAQAA5Sx5cRC2rV78bFA3eNvz3z/yLfcD9nJy7/TnvzWHLO79a8SrgTWtxV4unPZ46gsMj5v6GnffWnmSpowL7uO42YRsiEcF3kTsZFrGO1eIeTwldN6IfHI3XuhYEuvo9p1Q+kP/9+Ky1rGJHCadqhpYxM5ahkqaLr9Aq4SM93e5IAqEMVNbOIZktbURDBpQaykoFKmvNjEq2CgXidvUVXtBzRXweSMucJUCF10Gis1bysoJDGCPz3GHXE+j4yb4BeaeDugpLZ8lv5976By7wSGOtmsig1VDT5PXGIK7U625rni04ZtBupRZaEWjpTEaIT75jEszZlCD0XmxWulM9hV++OjMxaubsZh7Z3fnJz11fDy+YrItlxOk/KUbzK6UxA==; TATravelInfo=V2*A.2*MG.-1*HP.2*FL.3*RS.1*RY.2022*RM.6*RD.17*RH.20*RG.2; TAReturnTo=%1%%2FRestaurant_Review-g188590-d13511379-Reviews-Restaurant_Bougainville-Amsterdam_North_Holland_Province.html; OptanonConsent=isGpcEnabled=0&datestamp=Fri+Jun+17+2022+20%3A11%3A08+GMT%2B0800+(%E4%B8%AD%E5%9B%BD%E6%A0%87%E5%87%86%E6%97%B6%E9%97%B4)&version=6.30.0&isIABGlobal=false&hosts=&consentId=cc7e2f72-5007-428f-a72e-392f9741b69d&interactionCount=1&landingPath=NotLandingPage&groups=C0001%3A1%2CC0002%3A1%2CC0003%3A1%2CC0004%3A1&AwaitingReconsent=false; TATrkConsent=eyJvdXQiOiIiLCJpbiI6IkFMTCJ9; _pbjs_userid_consent_data=3524755945110770; _li_dcdm_c=.tripadvisor.com; __gpi=UID=000006b77138250b:T=1655467873:RT=1655467873:S=ALNI_MbOL4NX_tligitacN_KwB6PemYWqQ; SRT=TART_SYNC; TART=%1%enc%3AfD9OzCOGTHLKxR1qLNfmGZurd9xliidHT5bmQw2z505WnDQeBJdPDWc64WFlxikpNox8JbUSTxk%3D; _lr_sampling_rate=100; _lr_retry_request=true; _lr_env_src_ats=false; __li_idex_cache=%7B%7D; pbjs_li_nonid=%7B%7D; bm_sv=3B18902AF4DC3FB5C636585CAC8FF658~YAAQyDUduD5EZnGBAQAA2QmZcRDjjMYTHv4xqU4lD0E4d7Xj0WV5dQ/46jlfYTucTGl1yWVUXsAP3PcgXzxtrrNWkcjCugvrDcZNXH0mxKOlYlKNM3jWWQOOSt+Jen/ideuJLQAMpPBgXrEMW2v1qE1sM/09r8Wk1Jgb26a+Q9sao40/k/ESyx4ebtpyRkziMRByxOYBbirkTsVL/y7CYMPE8yVQqbiPQdHPem6GMrv+bp87L4gY9qqm7Z+g5eYWzimgOMkkWA==~1; __vt=SVdeZUe-0PX0kT-WABQCIf6-ytF7QiW7ovfhqc-AvR4ZUmM-8Xj_P7I6kBFYa-jE0Q5YcrsWTyJBGYS785HCCtk1Q1VlPRKksZAdqcsat21B56Go8VSeHHLIrlMmQ_OXo1YDVqVWeeFaKIh9pT3zHxOIvQ; roybatty=TNI1625!AF5lFidAXBie9fDE6jtKPZJbwpAH%2BdfYfemV%2FITVap8g312LO2OHEcRltEyEH1LU3KJ3IEadn4T4WB3lp%2BUqrWejbt9xHvyqboOAsCMoy1AI0wp2xItYlmihjGJ3Je%2FFAvbl9HW9bauuGGpnXM6W82PUibGqAIeVfxEwWnB2hFTH%2C1; TASession=V2ID.023207A6A44049DBBF0ACA838F764F72*SQ.30*LS.DemandLoadAjax*GR.9*TCPAR.43*TBR.37*EXEX.33*ABTR.12*PHTB.75*FS.38*CPU.34*HS.recommended*ES.popularity*DS.5*SAS.popularity*FPS.oldFirst*LF.en*FA.1*DF.0*TRA.false*LD.13511379*EAU._; TAUD=LA-1655364516989-1*RD-104046361-2022_06_17.13511379*LG-104047238-2.1.F.*LD-104047239-.....',
# Anti theft chain
'referer': '',
# Browser basic information
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'
}
url_ = ''
list_html = requests.get(url=url_, headers=headers).text
list_select = parsel.Selector(list_html)
link_list = list_select.css('.bGnIM .OhCyu span a::attr(href)').getall()
for link in link_list:
url = '' + link

3、 ... and 、 Send a request

 response = requests.get(url=url, headers=headers)

Four 、 get data

 html_data = response.text

5、 ... and 、 Parsing data

 # Lighten the burden
# Interview questions Examination content
selector = parsel.Selector(html_data)
store_name = selector.css('.fHibz::text').get()
comment_count = selector.css('.eSAOV.H3:nth-child(2) .eBTWs::text').get()
address = selector.css('.eSAOV.H3:nth-child(3) .dyeJW.dUpPX:nth-child(1) a::text').get()
# :nth-child(3): Select the number of tabs Collect multiple pages of content
Source code 、 answer 、 Data can be added Q skirt :832157862 Free collection
phone = selector.css('.eSAOV.H3:nth-child(3) .dyeJW.dUpPX:nth-child(2) a::text').get()
score = selector.css('.eEwDq .fdsdx::text').get()
print(store_name, comment_count, address, phone, score)

Tail language

Okay , My article ends here !

There are more suggestions or questions to comment on or send me a private letter ! Come on together and work hard (ง •_•)ง

If you like, just pay attention to the blogger , Or like the collection and comment on my article !!!


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved