can't get <p>'s text when useing python scrapy a website
<p>Here is the website's source html code:</p>

<pre><code>      &lt;p class="fc-gray"&gt;
           hello
       &lt;span class=""&gt;2010-10&lt;/span&gt; 
       &lt;em class="shuxian"&gt;|&lt;/em&gt;
             4.2                 
      &lt;/p&gt;
</code></pre>

<p>I want to get the value 4.2.
The following is my code (carInfoDiv is a xpath element selector): </p>

<pre><code>        miles = carInfoDiv.xpath("p[contains(@class,'fc-gray')]/text()").extract()[0]
</code></pre>

<p>in this way, I got the string 'hello', I have also tried string(.), but got all string in <code>&lt;p&gt;</code>, not the result I wanted. Please show me how to get only 4.2 in this situation.</p>

<p>I don't know xpath very much. but regular expression may help you</p>

<p>this is not so elegant, but will work for you</p>

<pre><code>&gt;&gt;&gt; import re
&gt;&gt;&gt; html = """
    &lt;p class="fc-gray"&gt;
       hello
    &lt;span class=""&gt;2010-10&lt;/span&gt;
    &lt;em class="shuxian"&gt;|&lt;/em&gt;
         4.2
    &lt;/p&gt;
"""
&gt;&gt;&gt; search = re.search('em&gt;[\n\s]*(?P&lt;result&gt;[\d.]+).*', html, flags=re.DOTALL)
&gt;&gt;&gt; if search:
...     print(search.group('result'))
...     
4.2
</code></pre>

python scrapy