1

I have most of the class name are same, i am not able to extract a specific information.

 <div class="block-record-info">
    <div class="title3">Author Information</div>
    <p class="FR_field">
    <span class="FR_label">Reprint Address: </span>
    Havens, T (reprint author)
    </p>
    <table class="FR_table_noborders" rules="NONE" cellspacing="0" cellpadding="0" border="0">
    <p/>
    <p class="FR_field">
    <span class="FR_label">Addresses:   </span>
    </p>
    <table class="FR_table_noborders" rules="NONE" cellspacing="0" cellpadding="0" border="0">
    <p/>
    </div>
    <div class="block-record-info">
    <div class="title3">Publisher</div>
    <p class="FR_field">
    <value>SOC JAPANESE STUD, UNIV WASHINGTON THOMSON HALL DR-05, SEATTLE, WA 98195 USA</value>
    </p>
    </div>
    <div class="block-record-info">
    <div class="title3">Categories / Classification</div>
    <p class="FR_field">
    <span class="FR_label">Research Areas:</span>
    Area Studies; Asian Studies
    </p>
    <p class="FR_field">
    <span class="FR_label">Web of Science Categories:</span>
    Area Studies; Asian Studies
    </p>
    </div>

i want output like this

Publisher 

SOC JAPANESE STUD, UNIV WASHINGTON THOMSON HALL DR-05, SEATTLE, WA 98195 USA
Research Areas

Area Studies; Asian Studies

Web of Science Categories

Area Studies; Asian Studies

how do i get it?

1
  • 1
    There are several occurrences of <div class="title3">, but the one you want has the specific text Publisher, so you should be able to find it easily. What have you tried? Commented Jun 25, 2017 at 7:16

1 Answer 1

1

You can get the output you want by following the approach mentioned below.

Code:

# Print the "Publisher" text.
print driver.find_element_by_xpath("//div[@class='block-record-info']/div[@class='block-record-info'][1]/div").text

# Print the other paragraph text which you have specified in your output.

records = driver.find_elements_by_xpath('//div[@class="block-record-info"]/div[@class="block-record-info"]')

for record in records:
print record.find_element_by_xpath('.//p').text
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.