Я хочу зациклиться на этом коде.
<pre lang="Python">import requests from bs4 import BeautifulSoup import re import json def lol(url): with requests.Session() as req: r = req.get(url) soup = BeautifulSoup(r.content, 'html.parser') vs = soup.find("input", id="__VIEWSTATE").get("value") ev = soup.find("input", id="__EVENTVALIDATION").get("value") data = { "__EVENTTARGET": "", "__EVENTARGUMENT": "", "__VIEWSTATE": vs, "__VIEWSTATEGENERATOR": "FE3EF141", "": [ "{2}", "" ], "ctl00_rwmWindowManager_ClientState": "", "ctl00_rwTimeoutWarning_ClientState": "", "s": "", "ctl00$PageContent$orgOption": "rbHaveOrg", "ctl00$PageContent$ddlOrganization": "-", "ddlOrganization_ClientState": "{\"logEntries\":[],\"value\":\"048447c3-0007-c47b-7c9e-0b3e39483880\",\"text\":\"-\",\"enabled\":true}", "ctl00$PageContent$tbLoginID": "", "ctl00$PageContent$tbPassword": "", "ctl00$PageContent$tbConfirmPassword": "", "ctl00$PageContent$tbIndividualFirstName": "", "ctl00$PageContent$tbIndividualLastName": "", "ctl00$PageContent$tbIndividualSuffix": "", "ctl00_PageContent_tbIndividualSuffix_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"\",\"enabled\":true}", "ctl00$PageContent$tbIndividualEmail": "", "ctl00$PageContent$gvIndividualPhoneNumbers$ctl02$tbIndividualPhoneNumber": "", "ctl00$PageContent$gvIndividualPhoneNumbers$ctl03$tbIndividualPhoneNumber": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$hfIndividualAddressCode": "Home", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$Line1": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$Line2": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$PostalCode": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$City": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$State": "", "ctl00_PageContent_rptIndividualAddresses_ctl00_acIndividualAddress_State_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"\",\"enabled\":true}", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$Country": "No Country", "ctl00_PageContent_rptIndividualAddresses_ctl00_acIndividualAddress_Country_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"No Country\",\"enabled\":true}", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$County": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$CongressionalDistrict": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$CASSCertificationDate": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$CarrierRoute": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$DeliveryPointCheckDigit": "", "ctl00$PageContent$rptIndividualAddresses$ctl00$acIndividualAddress$DeliveryPointCode": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$hfIndividualAddressCode": "Work", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$Line1": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$Line2": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$PostalCode": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$City": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$State": "", "ctl00_PageContent_rptIndividualAddresses_ctl01_acIndividualAddress_State_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"\",\"enabled\":true}", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$Country": "No Country", "ctl00_PageContent_rptIndividualAddresses_ctl01_acIndividualAddress_Country_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"No Country\",\"enabled\":true}", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$County": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$CongressionalDistrict": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$CASSCertificationDate": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$CarrierRoute": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$DeliveryPointCheckDigit": "", "ctl00$PageContent$rptIndividualAddresses$ctl01$acIndividualAddress$DeliveryPointCode": "", "ctl00$PageContent$ddlIndividualPreferredAddress": "048447c3-000f-c2ac-8bfc-0b3d04988fbc", "ctl00$PageContent$chkDoNotMail": "on", "ctl00$PageContent$chkDoNotFax": "on", "ctl00_PageContent_dlbMessageCategories_lbSrc_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00_PageContent_dlbMessageCategories_lbDest_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00$PageContent$cfsIndividualCustomFields$TextBox1": "", "ctl00$PageContent$cfsIndividualCustomFields$TextBox3": "", "ctl00$PageContent$cfsIndividualCustomFields$TextBox4": "", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox5": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox5_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox6": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox6_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox7": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox7_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox8": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox8_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox9_lbSrc_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox9_lbDest_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox10_lbSrc_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox10_lbDest_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00$PageContent$cfsIndividualCustomFields$RadDatePicker11": "", "ctl00_PageContent_cfsIndividualCustomFields_RadDatePicker11_dateInput_text": "", "ctl00$PageContent$cfsIndividualCustomFields$RadDatePicker11$dateInput": "", "ctl00_PageContent_cfsIndividualCustomFields_RadDatePicker11_dateInput_ClientState": "{\"enabled\":true,\"emptyMessage\":\"\",\"minDateStr\":\"1/1/1 0:0:0\",\"maxDateStr\":\"12/31/9999 0:0:0\"}", "ctl00_PageContent_cfsIndividualCustomFields_RadDatePicker11_calendar_SD": "[]", "ctl00_PageContent_cfsIndividualCustomFields_RadDatePicker11_calendar_AD": "[[1,1,1],[9999,12,31],[2020,3,24]]", "ctl00_PageContent_cfsIndividualCustomFields_RadDatePicker11_ClientState": "{\"minDateStr\":\"1/1/0001 0:0:0\",\"maxDateStr\":\"12/31/9999 0:0:0\"}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox12": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox12_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox13": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox13_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox14": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox14_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox15": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox15_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$TextBox16": "", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox17_lbSrc_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox17_lbDest_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00$PageContent$cfsIndividualCustomFields$TextBox18": "", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox19": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox19_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00$PageContent$cfsIndividualCustomFields$RadComboBox20": "---- Select ----", "ctl00_PageContent_cfsIndividualCustomFields_RadComboBox20_ClientState": "{\"logEntries\":[],\"value\":\"\",\"text\":\"---- Select ----\",\"enabled\":true}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox21_lbSrc_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "ctl00_PageContent_cfsIndividualCustomFields_DualListBox21_lbDest_ClientState": "{\"isEnabled\":true,\"logEntries\":[],\"selectedIndices\":[],\"checkedIndices\":[],\"scrollPosition\":0}", "__CALLBACKID": "ctl00$PageContent$ddlOrganization", "__CALLBACKPARAM": "{\"Command\":\"LOD\",\"Text\":\"-\",\"ClientState\":{\"value\":\"\",\"text\":\"\",\"enabled\":true,\"logEntries\":[]},\"Context\":{\"Text\":\"-\",\"NumberOfItems\":40},\"NumberOfItems\":40}", "__EVENTVALIDATION": ev } r = requests.post(url, data=data) try: goal = re.search(r"\=(\[.+])", r.text).group(1) except: goal = None clear = json.loads(goal) print(json.dumps(clear, indent=4)) lol("https://cmt.ps.membersuite.com/profile/CreateAccount_CreateUser.aspx")
Что я уже пробовал:
Consider that it's giving you the first 20 rows :) but no worries. You can loop over the POST request with +20 on the following parameter __CALLBACKPARAM where you will need to change "NumberOfItems\":0 with +20 on each POST :)
Kris Lantz
Так... где же ты застрял?
ZurdoDev
И что же?
Patrice T
У вас есть проблема, кроме того, что вы ничего не пробовали ?
Member 14791717
Я не прошу сделать это полностью для меня, я думаю, что не объяснил это хорошо, может быть, это то, что мне нужно. дай мне попробовать еще раз так что,
Вот ссылка на сайт # https://cmt.ps.membersuite.com/profile/CreateAccount_CreateUser.aspx
Ниже есть выпадающая вкладка ( я связан с компанией ниже). когда мы нажимаем на него, он показывает другую информацию об организации, которую в основном я хочу очистить.
Приведенный выше код просто дает мне 20 строк, но когда я пытаюсь изменить следующие параметры "NumberOfItems\":0 from _CALLBACK. Тогда это дает мне ошибку. Когда я следую за запросом post из заголовков, проверяя элементы, он показывает, что этот параметр повторяется на +20 для каждого запроса. Но когда я пытаюсь сделать это для "NumberOfItems\":40 или "NumberOfItems\":40, которые являются допустимыми параметрами запроса, но я не могу найти результаты. Я не могу быть некоторые другие параметры должны быть изменены, а также которые я пропускаю, так что именно поэтому я опубликовал вопрос, так что любой может помочь мне найти это. позвольте мне также опубликовать этот код.
Здесь выводится 20 строк:
[
{
"текст": "-",
"значение": "048447c3-0007-c47b-7c9e-0b3e39483880",
"атрибуты": {
"ROW_NUMBER": "1",
"LocalID": "10619",
"Введено": "jamiebolton@hotmail.com",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "-",
"значение": "048447c3-0007-ced2-814b-0b400d0f470f",
"атрибуты": {
"ROW_NUMBER": "2",
"LocalID": "11477",
"Введено": "rpt@gwu.edu",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "Banco Internacional del Per\u00fa - межбанк",
"значение": "048447c3-0007-c0e0-6c76-0b3e66b7e1ec",
"атрибуты": {
"ROW_NUMBER": "3",
"LocalID": "10703",
"Введено": "dalvarezc84@gmail.com",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "Бишоп-Макдональдс богатство Mgmt Group",
"значение": "048447c3-0007-c6d0-d748-03bda528b59f",
"атрибуты": {
"ROW_NUMBER": "4",
"LocalID": "11697",
"Адрес электронной почты": "",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "BOB-Caridif Life Insurance Co.,Ltd.",
"значение": "048447c3-0007-c8b1-bbf2-0b3d578797ea",
"атрибуты": {
"ROW_NUMBER": "5",
"LocalID": "10094",
"Введено": "bingxinshi@163.com",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "CEFS Verm\u00f6gensverwaltungs - und Beteiligungs GmbH",
"значение": "048447c3-0007-c88c-9064-0b3df4010a50",
"атрибуты": {
"ROW_NUMBER": "6",
"LocalID": "10467",
"Введено": "sergiufala@gmail.com",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "CGS-CIMB",
"значение": "048447c3-0007-c74a-918b-0b3e7c42f6a0",
"атрибуты": {
"ROW_NUMBER": "7",
"LocalID": "10753",
"Введено": "joelap0506@gmail.com",
"_Preferred_Address_City": "",
"_Preferred_Address_State": "",
"Статус.ShowInQuickSearches": "Правда"
}
},
{
"текст": "CMT - Denver Chapter",
"значение": "048447c3-0007-c603-99e4-0b3deeb54833",
"атрибуты": {
"ROW_NUMBER": "8",
"LocalID": "10446",