Ну, я вижу, что вы просто звоните на главный url
и это все? Как вам, кроме анализа, если вы даже не собрали urls
в основном url
, а затем вызвать каждый url
для его анализа.
Даже если вы используете selenium
для таких задача, которая полностью замедлит вашу работу. для этого вам необходимо прочитать документацию по селену , чтобы понять, как используется selenium
.
Вы не включили sample
желаемого результата. и есть вещи, которые я не мог понять, такие как level
. В любом случае, так как вы не можете помочь в предоставлении четкой информации.
приведенный ниже код должен достичь вашей цели:
import requests
from bs4 import BeautifulSoup
def First():
r = requests.get("https://global.remax.com/handlers/officeagentsearch.ashx?mode=list&type=2®ionId=1000®ionRowId=&provinceId=&cityId=&localzoneId=&name=&location=&spokenLanguageCode=&page=1&countryCode=US&countryEnuName=USA&countryName=USA&selmode=residential&officeId=&TargetLng=&TargetLat=")
soup = BeautifulSoup(r.text, 'html.parser')
data = []
for href in soup.find_all("a", class_="agent-name"):
href = href.get("href"), href.text
data.append(href)
return data
def Second():
for url, name in First():
print(f"Extracting {name}")
print('*' * 40)
with requests.Session() as req:
r = req.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
phone = [item.get_text(strip=True) for item in soup.findAll(
"span", {'id': ['AgentDirectDialSpan', 'OfficePhoneSpan', 'PhoneSpan']})]
print(phone)
addr = [item.get_text(strip=True, separator=" ") for item in soup.findAll(
"span", id="ctl05_OfficeAddress")]
print(addr)
emailandurl = soup.find("a", {'class': 'url'})
email = emailandurl.text
url = emailandurl.get("href")
if not "@" in email:
email = "N/A"
if "@" in url:
url = "N/A"
print(f"Email : {email}, Url: {url}")
print('*' * 40)
Second()
Вывод:
Extracting Jim & Lisa - THE COOPERS
****************************************
['+1 816-260-1459', '+1 816-781-9080', '+1 816-260-8592']
['2 Victory Dr Liberty, Missouri, United States 64068']
Email : N/A, Url: http://soldbythecoopers.com
****************************************
Extracting Jim & Jimmie Rucker - The Rucker Group
****************************************
['+1 816-739-5289', '+1 816-781-9080', '+1 816-739-5289']
['2 Victory Dr Liberty, Missouri, United States 64068']
Email : N/A, Url: http://jimmierucker.remax-midstates.com
****************************************
Extracting The Steve & Shauna Faught Team !
****************************************
['+1 8053829441', '+1 (805) 208-1826']
['1151 S Victoria Ave Oxnard, California, United States 93035']
Email : shaunafaught@remax.net, Url: N/A
****************************************
Extracting Vickie Soupos & Georgia Colovos
****************************************
['+1 847.352.5200', '+1 847-352-5200', '+1 630.965.6000']
['1080 Nerge Rd. Suite 204 Elk Grove Village, Illinois, United States 60007']
Email : N/A, Url: http://vickiecsoupos.engagereagent.com
****************************************
Extracting Steven Roque & Jan Meyer
****************************************
['+1 (858) 451-6541', '+1 8583915800', '+1 (858) 451-6541']
['16840 Bernardo Center Dr. San Diego, California, United States 92128']
Email : stevenproque@remax.net, Url: N/A
****************************************
Extracting Gabrielle (clark) Lawson
****************************************
['+1 (937) 778-3961', '+1 9377783961', '+1 (937) 418-1718']
['1200 Park Ave Piqua, Ohio, United States 45356']
Email : brandi.clark@remax.net, Url: N/A
****************************************
Extracting The Beauchamp Team (Pam & Heather)
****************************************
['+1 3867588900', '+1 (386) 303-2505']
['4255 SW Cambridge Glen Lake City, Florida, United States 32024-3431']
Email : pamelabeauchamp@remax.net, Url: N/A
****************************************
Extracting Amanda (Ritter) Lease
****************************************
['+1 6128125732', '+1 (952) 475-8000', '+1 6128125732']
['125 Lake St West Wayzata, Minnesota, United States 55391']
Email : N/A, Url: http://amandalease.results.net
****************************************
Extracting The Manring Brothers @ REMAX
****************************************
['+1 (239) 289-6913', '+1 2397932777', '+1 (239) 289-6915']
['877 91st Ave N Suite 2 Naples, Florida, United States 34108']
Email : tylermanring@remax.net, Url: N/A
****************************************
Extracting Logan M. Aal
****************************************
['+1 (303) 456-2153', '+1 3034205352', '+1 (303) 501-0294']
['5440 Ward Rd Ste 110 Arvada, Colorado, United States 80002']
Email : loganaal@remax.net, Url: N/A
****************************************
Extracting Abe Aalami
****************************************
['+1 (425) 743-1639', '+1 2063225700', '+1 (206) 948-6283']
['2312 Eastlake Ave E Seattle, Washington, United States 98102']
Email : abe.aalami@remax.net, Url: N/A
****************************************
Extracting Lacey Aalderks
****************************************
['+1 3202311221', '+1 (320) 266-1631']
['770 N Business Hwy 71 Willmar, Minnesota, United States 56201']
Email : N/A, Url: http://www.laceyaalderks.com
****************************************
Extracting Andrea Aana
****************************************
['+1 (808) 935-8300', '+1 8089359800', '+1 (808) 937-6396']
['88 Kanoelehua Ave #A-105 Hilo, Hawaii, United States 96720']
Email : andreaaana@remax.net, Url: N/A
****************************************
Extracting Adam Aaron
****************************************
['+1 3039854555', '+1 (225) 571-5111']
['143 Union Blvd Ste 120 Lakewood, Colorado, United States 80228-1827']
Email : Adam.Aaron@remax.net, Url: N/A
****************************************
Extracting Bryan Aaron
****************************************
['+1 2812456463', '+1 (832) 526-1973']
['203 S Friendswood Dr Ste 200 Friendswood, Texas, United States 77546-3901']
Email : Bryan.Aaron@remax.net, Url: N/A
****************************************
Extracting Lindsey Aaron
****************************************
['+1 (877) 407-2676']
['7101 Vista Drive West Des Moines, Iowa, United States 50266']
Email : N/A, Url: http://lindseyaaronrealestate.com
****************************************
Extracting Mary Aaron
****************************************
['+1 (214) 802-3954', '+1 9724628181']
['500 S Denton Tap Ste 110 Coppell, Texas, United States 75019']
Email : betha@remax.net, Url: N/A
****************************************
Extracting Noelle Aasen
****************************************
['+1 (317) 863-4088', '+1 3178497653', '+1 (317) 627-2120']
['5645 Castle Creek Parkway North Dr. Indianapolis, Indiana, United States 46250']
Email : N/A, Url: http://151354589.homesconnect.com
****************************************
Extracting Kristy Aasheim
****************************************
['+1 4068962200']
['517 S 24th St W Ste A Billings, Montana, United States 59102']
Email : kristyaasheim@remax.net, Url: N/A
****************************************
Extracting Kristy L. Aasheim
****************************************
['+1 (406) 480-9383', '+1 7015808116']
['115 2nd Ave W Williston, North Dakota, United States 58801-5918']
Email : kaasheim@remax.net, Url: N/A
****************************************