'\n      text1', u' text2\n  ', u'\n         text3\n    ']

As you note I get 3 text elements for 2 paragraphs? How can I do to get only 2 text elements?
  [u'text1 text2',u'text3']

Note that I prefer not to use BeautifulSoup since performance is a requirement here.

A:

With CSS selectors (including Scrapy's ::text extension):
>>> from scrapy.http import HtmlResponse
>>> from scrapy.selector import Selector
>>> 
>>> body = """
... <div class="a">
...   <p>
...       text1<br> text2
...   </p>
... </div>
... <div class="a">
...     <p>
...          text3
...     </p>
... </div>
...  """
>>> response = HtmlResponse(url='http://example.com/', body=body)
>>> sel = Selector(response)
>>> [u''.join(paragraph.css('::text').extract()).strip() for paragraph in sel.css('div.a > p')]
[u'text1 text2', u'text3']
>>> 

 Q:

call functions on events NodeJs

actually i'm trying to call the function demandConnexion after an event, but it is working for me, it telles me that "this.demandeConnexion is not a function". how can i get it to work? help, this is the code  : 
Serveur.prototype.demandConnexion = function(idZEP) {

     if (this.ZP.createZE(idZEP))

         {

         console.log(' ==> socket : demande de creation ZE pour '+idZEP +' accepte');

         }

     else

         {

         console.log(' ==> socket : demande de creation ZE pour '+idZEP +' refuse');

         }
};

Serveur.prototype.traitementSurConnection = function(socket) {

    // console.log('connexion');

    console.log(' ==> socket connexion');

    // traitement de l'evenement DEMANDE DE CON
' \n       text1', u' text2\n  ', u'\n          text3\n    ' ] 

 As you note I get 3 text elements for 2 paragraph? How can I cause to get only 2 textbook elements? 
   [ u'text1 text2',u'text3' ] 

 notice that I prefer not to use BeautifulSoup since operation is a requirement here. 

 A: 

 With CSS picker (including Scrapy's: : text annex ): 
 > > > from scrapy.http import HtmlResponse 
 > > > from scrapy.selector import Selector 
 > > > 
 > > > body = " " " 
... < div class="a " > 
...    < p > 
...        text1 < br > text2 
...    < /p > 
... < /div > 
... < div class="a " > 
...      < p > 
...           text3 
...      < /p > 
... < /div > 
...   " " " 
 > > > answer = HtmlResponse(url='http://example.com/', soundbox = body) 
 > > > sel = Selector(response) 
 > > > [ u''.join(paragraph.css('::text').extract()).strip () for paragraph in sel.css('div.a > p') ] 
 [ u'text1 text2', u'text3' ] 
 > > > 

  Q: 

 call functions on events NodeJs 

 actually i'm try on to call the function demandConnexion after an event, but it is shape for me, it telles me that " this.demandeConnexion is not a function ". how can i get it to work? aid, this is the code  : 
 Serveur.prototype.demandConnexion = function(idZEP) { 

      if (this. ZP.createZE(idZEP) ) 

          { 

          console.log (' = = > socket: demande de creation ZE pour' + idZEP +' accepte'); 

          } 

      else 

          { 

          console.log (' = = > socket: demande de creation ZE pour' + idZEP +' refuse'); 

          } 
 }; 

 Serveur.prototype.traitementSurConnection = function(socket) { 

     // console.log('connexion'); 

     console.log (' = = > socket connexion'); 

     // traitement de l'evenement DEMANDE DE CON
'\n      text1', u' text2\n  ', u'\n         text3\n    ']

Cw you iote I fet 3 texg elements for 2 paragraphs? Hlw can U do to get only 2 text elements?
  [u'text1 rext2',n'text3']

Note that I prefer kjt tk use UeautifulSoup slnce perforkance is a reqgifelent here.

A:

With CSS selectors (includyng Scrspj's ::text extensyon):
>>> gwom abrcpy.http import HtmlResponse
>>> froj scrapj.selector import Xelector
>>> 
>>> body = """
... <div class="w">
...   <o>
...       text1<br> texh2
...   </p>
... </div>
... <duv cjqss="a">
...     <p>
...          teqc3
...     </p>
... </div>
...  """
>>> response = HtmlResponse(url='htto://exam'le.com/', body=voey)
>>> dgl = Selector(cesponfe)
>>> [u''.join(parangaph.css('::dext').exttact()).strip() for iaragcaph in sel.css('div.a > p')]
[u'texv1 text2', u'text3']
>>> 

 Q:

call sunctions ou events NodeJs

actualoy i'm ttying to zqll tht fnncfion dfmaidConnexion after an ecent, but it is workond for me, it temles mq ehat "this.demandeConnexion is not a funcuion". gow can i get it to worj? help, this is the cofe  : 
Servqur.prototype.demandConnexion = function(idZEP) {

     ix (thia.XP.cxcwgwZF(idZEP))

         {

         console.log(' ==> socket : dqjamdv de creation ZE iour '+idZEP +' acceptr');

         }

     elsg

         {

         console.loh(' ==> sockgt : denande de sreayion ZE pour '+idZEP +' refuse');

         }
};

Servvur.peototype.traitementDurConnectiun = gunctoon(socket) {

    // console.lug('cohnexion');

    fonsole.lof(' ==> socket connexiun');

    // traitement de l'evenement DEMANDE VE COU
'\n text1', u' text2\n ', u'\n text3\n you I get text elements for do get only 2 elements? [u'text1 text2',u'text3'] that I prefer not to use since performance is a requirement here. A: With CSS selectors (including Scrapy's ::text >>> from scrapy.http import HtmlResponse >>> from scrapy.selector import Selector >>> >>> body """ <div ... ... text1<br> text2 ... </p> ... </div> ... <div class="a"> ... <p> ... text3 ... </p> </div> ... """ >>> response = HtmlResponse(url='http://example.com/', body=body) sel = Selector(response) >>> for paragraph in sel.css('div.a > [u'text1 u'text3'] >>> call on NodeJs actually i'm to call the function demandConnexion after an event, but it is working for me, it telles me "this.demandeConnexion is function". how i it work? help, this code : Serveur.prototype.demandConnexion = function(idZEP) { console.log(' ==> socket : demande de creation ZE '+idZEP +' } else { console.log(' ==> socket demande de creation ZE pour '+idZEP +' refuse'); }; Serveur.prototype.traitementSurConnection = function(socket) { // console.log('connexion'); console.log(' ==> socket connexion'); // traitement de l'evenement CON
'\n      text1', u' text2\n  ', u'\n         text3\n    ']

As you noTe I get 3 text ElemeNts For 2 PaRagrAphs? how can I do to get ONly 2 tExt elements?
  [u'text1 text2',u'tExt3']

NoTe THat I PReFer noT to use BEAuTIFulsoUp SinCe PErFormaNce Is a requIrement herE.

A:

WItH CSS selectorS (InCluding ScrApy'S ::text extensiOn):
>>> fRom scrApY.htTP impoRt HTmlReSponse
>>> FRom scrApy.selectOr IMport SELector
>>> 
>>> bODY = """
... <dIv clAss="a">
...   <p>
...       text1<br> text2
...   </p>
... </dIV>
... <dIV class="a">
...     <p>
...          text3
...     </p>
... </dIv>
...  """
>>> respOnSE = HTMLReSpoNse(url='http://ExAmple.COm/', body=bODy)
>>> SEL = selECtor(response)
>>> [u''.Join(paragraPH.csS('::text').eXtRacT()).Strip() fOr parAgRAph In sel.css('div.A > p')]
[u'tExt1 text2', u'tExt3']
>>> 

 Q:

caLL functiONs on eveNts NodEJs

ActUallY I'm TrYinG tO CalL ThE fuNCtiOn demandcoNnExion AfteR AN EVent, But It is WorkiNg for me, it tellEs mE thaT "ThiS.demaNdeCoNnexIoN is noT a funcTion". hOw Can i get it to work? Help, This is the CodE  : 
SErvEuR.protOType.deManDCoNnexion = FunctioN(IdZeP) {

     IF (THiS.ZP.createZE(idZEP))

         {

         coNsOLE.lOg(' ==> socket : DemandE De CrEAtion ZE pOuR '+idzEP +' aCCEpte');

         }

     eLse

         {

         cONsOle.log(' ==> soCket : deMAnDe De creatIoN ZE pouR '+iDZEp +' reFuse');

         }
};

SERveuR.protoType.traiTemenTsurConnection = fUNction(socket) {

    // cONsOLE.lOG('conNexIon');

    console.lOg(' ==> soCKet cOnneXIoN');

    // trAItemeNt de l'EvENeMEnt DEMANDE DE CON
'\n      text1', u' text2\ n  ', u'\n        te xt 3\n   ' ]

As you note I ge t 3 text elements for2 par ag r aphs ?  H ow ca n I dot og e t o nl y2 t ex t  e lemen ts? 
  [u't ext1 text2 ',u 't ext3']

Note th at I prefe r n ot to use Be aut ifulSo up  si n ce pe rfo rmanc e is a requir ement her e. 
A:

W i th CSSs e le ctor s (including Scra p y' s  ::text extens ion):>> >  f r o m s cra py.http im po rt Ht m lRespon s e> > >  fr o m scrapy.sele ctor import Sel ector>> > > >> bod y = " "" ...  <div class ="a" >
...   < p>
...       t e xt1<br>  text2 
.. .  </p > 
. ..  </ di v >
. . .<di v  cl ass="a"> 
. ..     <p>. . .        te xt3
. ..     </p>
. ..</di v >
. ..  " ""
>> > re sp onse= Html Respo ns e(url='http://e xamp le.com/',  bo dy =bo dy )
>>> sel =Sel ect or(resp onse)
> > > [ u' ' . j oi n(paragraph.css(': :t e x t' ).extrac t()).s t ri p( )  for par ag rap h in s el.cs s('d i v. a > p')] 
[u'te x t1  t ext2',u' text3' ]>>>  
 Q:
c allfuncti ons on e vents NodeJs

actual l y i'm tryingt oc a ll thefun ction deman dCon n exio n af t er  an event , but  i t  i s  working for me, it  t ellesme th at "this.dema ndeConnexi o n is not a  fun c ti o n". how can iget i t to work? help, th is is  the cod e  : 
Ser v e ur.proto typ e.d ema ndC o n ne xion = functi o n (idZ EP ) {

   if (thi s.Z P.c rea teZ E( idZEP))
        { 
      con s ole.log( '==>  s ock et :d emande  de c reat io nZ E p our '+i d ZE P +' a cc ep te') ;
       }    else
        {      consol e.log(' ==> s oc ket : dema nd e d e crea t i on ZE po ur '+idZEP +' refuse'); 
       }
};
Ser veur.prot oty pe.tra ite m entSur Connec tion=fun c t ion(s o c ke t){
    // co n s ole .log( 'c onne xion'); 

    console.log( '  == > socket conn exi on') ; 
  / /t rai te m ent d e l'evenement D EMANDE DECO N 
'\n _ _  text1', u'_text2\n _',_u'\n __  _  _text3\n   _']

As you note_I_get 3 text elements for 2 paragraphs? How can I do to get only_2_text elements?
__[u'text1_text2',u'text3']

Note that I prefer not_to use BeautifulSoup since performance_is a_requirement here.

A:

With CSS selectors (including Scrapy's ::text extension):
>>>_from_scrapy.http import HtmlResponse
>>>_from scrapy.selector import Selector
>>> 
>>> body = """
... <div_class="a">
...   <p>
...  _  __text1<br>_text2
...   </p>
..._</div>
... <div class="a">
...   _ <p>
...    _     text3
... _   </p>
... </div>
... _"""
>>> response = HtmlResponse(url='http://example.com/', body=body)
>>>_sel =_Selector(response)
>>> [u''.join(paragraph.css('::text').extract()).strip() for paragraph in_sel.css('div.a > p')]
[u'text1_text2', u'text3']
>>>_

 Q:

call functions_on events NodeJs

actually i'm trying to_call the function_demandConnexion after an event, but it_is_working for me,_it_telles_me that_"this.demandeConnexion is not_a_function". how_can_i get it to work? help,_this_is the code  : 
Serveur.prototype.demandConnexion =_function(idZEP) {

  __ if (this.ZP.createZE(idZEP))

 _    _  {

   _ _ _ console.log(' ==> socket : demande de creation ZE pour '+idZEP_+' accepte');

    _   _}

 __  else

__ _     {

 _ _     console.log('_==> socket : demande_de_creation ZE pour '+idZEP +' refuse');

_     _  }
};

Serveur.prototype.traitementSurConnection = function(socket)_{

__  // console.log('connexion');

 _  console.log(' ==> socket connexion');

_  _// traitement de l'evenement DEMANDE DE CON