简体   繁体   中英

Extracting specific info from web page using Python - BS4

I was already able to scrape this using ".find('div', class_"

div class="ListingCell-AllInfo ListingUnit" data-bathrooms="2" data-bedrooms="2" data-building_size="74.5" data-category="condominium" data-classification="" data-condominiumname="Amisa Private Residences" data-furnished="" data-geo-point="[124.0112408,10.3051555]" data-listing-new-development="true" data-price="15916180" data-price_range="15.9M - 16.1M" data-sku="CD62257FE69D224PH" data-subcategories='["condominium","double-bedroom"]' data-tower_name="Tower D"

but, what would be the code if i would like to extract this only:

[124.0112408,10.3051555]

from this segment?

just gonna answer my question because i now found out what to do:

below is my code:

num = str(all_info_main).index('data-geo-point=') print(str(all_info_main)[num+17:num+39])

.. but basically, you just need to find the index of the identifier, then print the characters after it.. just trial & error until you find the right values to print what you're looking for

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM