HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
不好意思,又做伸手黨了,這個(gè)問題我沒找到原因,不知道大神們有沒有遇到過
spring集成junit4報(bào)錯(cuò)如下:
翻譯之后大意是
是不是不能識(shí)別${jdbc.url}這句話呀,這個(gè)是配置在spring.xml中的,
而${jdbc.url}這個(gè)就是加載的jdbc.properties里的數(shù)據(jù)庫(kù)配置,我看這個(gè)配置沒啥問題啊,怎么就不行呢,我的測(cè)試類是這樣的:
是缺少什么嗎?我用的是MyBatis接口綁定開發(fā) ,沒有dao實(shí)現(xiàn)類那種,跟這個(gè)沒關(guān)系吧,哪位大神指點(diǎn)迷津一下
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
junit如何調(diào)試java web項(xiàng)目,在不用任何框架下
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
如果沒有多個(gè)模塊,十分簡(jiǎn)單,加兩個(gè)注解就好了: @RunWith(SpringRunner.class) @SpringBootTest
但在多模塊下這么做會(huì)報(bào)找不到Spring上下文的錯(cuò)誤。
查了各種資料,但還沒找到可行的辦法。網(wǎng)上流傳的有一定可行性的方法,是每個(gè)模塊都各自寫一個(gè)測(cè)試配置類。
但在測(cè)試的功能需要使用其余模塊的配置(properties文件和Configuration類)時(shí),依然會(huì)報(bào)錯(cuò)。
比如說(shuō)common模塊的配置類和配置文件,有數(shù)據(jù)庫(kù)連接等信息;而user模塊的功能測(cè)試需要用到。跑程序時(shí)沒問題,但單元測(cè)試時(shí)該如何獲取其余模塊的配置?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
在Spring Boot中使用Junit進(jìn)行測(cè)試,測(cè)試代碼如下: @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = WebPortalApplication.class) public class OTSLogDaoTest { @Autowired OTSLogDao otsLogDao; @Test public void getTrackInfo() throws Exception { List trackInfo = otsLogDao.getTrackInfo(new Date()); } }
結(jié)果運(yùn)行報(bào)錯(cuò),報(bào)錯(cuò)如下: java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:189) at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serverEndpointExporter' defined in class path resource [com/ipubtrans/wp/websocket/WebSocketConfig.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) ... 24 more Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available at org.springframework.util.Assert.state(Assert.java:70) at org.springframework.web.socket.server.standard.ServerEndpointExporter.afterPropertiesSet(ServerEndpointExporter.java:102) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ... 39 more
報(bào)錯(cuò)的創(chuàng)建失敗的類如下: @Configuration public class WebSocketConfig { @Bean public ServerEndpointExporter serverEndpointExporter() { return new ServerEndpointExporter(); } }
問題在于: 直接運(yùn)行程序不會(huì)報(bào)錯(cuò) 測(cè)試時(shí)才報(bào)錯(cuò)
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
現(xiàn)在,我正在做一個(gè)網(wǎng)站爬蟲,但是應(yīng)該是被一個(gè)網(wǎng)站視為攻擊了吧!我用瀏覽器訪問這個(gè)網(wǎng)站,顯示正常,但是程序訪問,返回的是電信的那個(gè)域名錯(cuò)誤;為了躲過限制:
1.采用了禁用cookie;
2.訪問google cache(由于學(xué)校上午必須安裝學(xué)校的客戶端,使用vpn一會(huì)后,就把我鏈接斷了);
3.使用torproject(tor被封了,要想使用需要使用vpn);
4.改變user-aget;
請(qǐng)問各位大神,還有什么方法可以嘗試?
悲劇的是現(xiàn)在瀏覽球也返回 http://sddnserror7.wo.com.cn:8080/issueunziped/baidusd121009/self0.jsp?UserUrl=www.woaidu.org 大神求指導(dǎo)
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> rt,使用scrapy shell測(cè)試語(yǔ)句:scrapy shell "http://list.jd.com/list.html?cat=670,671,2694" 也會(huì)出現(xiàn)exceptions.AttributeError: 'Response' object has no attribute 'body_as_unicode'這個(gè)問題,之前爬了幾個(gè)其他網(wǎng)站都可以,請(qǐng)教一下這是什么問題呢?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
如,一個(gè)將數(shù)據(jù)保存到excel文件的管道類,作為一個(gè)通用類,不寫死Item類的判斷過程,用dict來(lái)map類名和文件的關(guān)系, outputs = {‘AAAAAItem’: dict(wb=wb, ws=ws), 'BBBBBItem': dict(wb=wb, ws=ws), ...}
所以對(duì)于這個(gè)dict來(lái)說(shuō),只有來(lái)了一個(gè)新的沒見過的Item實(shí)例才會(huì)初始化與之對(duì)應(yīng)的文件。 def process_item(self, item, spider): output = self.outputs.get(item.item_name) # item_name換成type(item)也可以哈哈,一樣滴 if not output: # create file # ... output = dict(wb=wb, ws=ws) self.outputs[item.item_name] = output output['ws'].append([...]) return item
那么問題來(lái)了,Item們并發(fā)懟到這個(gè)pipeline里,在第一次的創(chuàng)建文件的過程中,會(huì)有線程安全之類的問題嗎?要加個(gè)雙重檢驗(yàn)鎖咩?(懶得看它的源碼是怎么調(diào)pipeline&自己些測(cè)試)
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 大家好,我剛開始學(xué)習(xí)使用scrapy,希望能請(qǐng)教一個(gè)問題。這是我的spiders文件夾中爬蟲文件的代碼 class PabhSpider(CrawlSpider): name = 'pabh' allowed_domains = ['xxx'] def start_requests(self): url = 'http://xxx' num1 = '01' formdata = { "depart":num, "years":'2014' } return [FormRequest(url=url,formdata=formdata,method='get',callback=self.parse)] def parse(self, response): item = XXXItem() hxs = Selector(response) item['bh'] = hxs.xpath('/html/body/form/p/font/select[3]/option/@value').extract() yield item num = ['02','03','04','05','06','07','08','09','10','11','12','13','14','21','31','40','51','61'] for x in num: url = 'http://xxx' formdata={ "depart":x, "years":'2014' } yield FormRequest(url=url,formdata=formdata,method='get',callback=self.parse)
我現(xiàn)在是這樣寫的。 我想不停的向一個(gè)url發(fā)送不同的get請(qǐng)求,然后獲得返回的數(shù)據(jù),現(xiàn)在這樣寫,返回的很多數(shù)據(jù)都是重復(fù)的, 而且不一定每次都能請(qǐng)求成功返回,有時(shí)候會(huì)發(fā)送同一個(gè)get參數(shù)兩次。
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
本人正在爬取一個(gè)網(wǎng)站,輸入網(wǎng)站地址后返回的是異步的ajax請(qǐng)求,
我想獲取所有的這些xhr以及它們的Form Data
請(qǐng)問有沒有辦法呢。困擾一天了 不知道怎么辦?
求大神解救一下,用的是python 以及Scrap'y
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
爬蟲源碼 def parse(self, response): data = json.loads(response.text)['result']['data'] if data is None: return for str in data: it_item = SinastarItem() it_item['userid'] = str['_id'] it_item['name'] = str['title'] it_item['starurl'] = str['url'] it_item['pic'] = str['pic'] if str['birth_year'] != '' and str['birth_month'] != '' and str['birth_day'] != '': it_item['birthday'] = str['birth_year'] + "/" + str['birth_month'] + "/" + str['birth_day'] else: it_item['birthday'] = '' it_item['xingzuo'] = str['astrology'] it_item['sex'] = str['gender'] it_item['profession'] = str['profession'] it_item['area'] = str['nationality'] it_item['height'] = str['height'] if not it_item['userid'] is None: intro_url = 'http://ent.sina.com.cn/ku/star_detail_index.d.html?type=intro&id=' + it_item['userid'] base_url = 'http://ent.sina.com.cn/ku/star_detail_index.d.html?type=base&id=' + it_item['userid'] photo_url = 'http://ent.sina.com.cn/ku/star_detail_index.d.html?type=photo&id=' + it_item['userid'] yield scrapy.Request(intro_url,callback=self.info_item,meta={'item':it_item,'type':'intro'}) yield scrapy.Request(base_url, callback=self.info_item, meta={'item': it_item,'type':'base'}) yield scrapy.Request(photo_url, callback=self.photo_item, meta={'item': it_item}) #寫真 def photo_item(self,response): item = response.meta['item'] photoji = response.xpath("http://*[@id='waterfall_roles']/li/a/img/@src").extract() ##取出寫真集 plen = len(photoji) if plen is not None and plen > 10: imgurl = random.sample(photoji, 10) ##隨機(jī)取list 10個(gè)數(shù) item['imgurl'] = ','.join(imgurl) else: if photoji is not None: item['imgurl'] = ','.join(photoji) else: item['imgurl'] = photoji return item ## 簡(jiǎn)介 def info_item(self, response): item = response.meta['item'] infodata = response.xpath("http://div[@class='detail-base']/p/text()").extract() if response.meta['type'] == 'intro': ##簡(jiǎn)介類型 item['intro'] = infodata else: item['base'] = infodata return item
管道Pipeline 源碼 def process_item(self, item, spider): data = dict(item) imgurl = data['imgurl'] base = data['base'] intro = data['intro'] userid = data['userid'] name = data['name'] sex = data['sex'] area = data['area'] xingzuo = data['xingzuo'] ##等于空 birthday = data['birthday'] ##等于空 height = data['height'] ##等于空 pic = data['pic'] profession = data['profession'] try: onlysql = " select * from tw_cms_article_star where userid ='%s'" % data['userid'] # 查重復(fù)id # 執(zhí)行sql語(yǔ)句 self.cur.execute(onlysql) # 是否有重復(fù)數(shù)據(jù) repetition = self.cur.fetchone() # 重復(fù) if repetition is not None: # 結(jié)果返回,已存在,則不插入 pass else: self.cur.execute("""insert into tw_cms_article_star (name,sex,area,xingzuo,birthday,height,pic,userid,intro,base,profession,imgurl) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) """ % [name,sex,area,xingzuo,birthday,height,pic,userid,intro,base,profession,imgurl]) #self.cur.execute(insersql) # 提交sql語(yǔ)句 self.mydb.commit() self.cur.close() except Exception as error: # 出現(xiàn)錯(cuò)誤時(shí)打印錯(cuò)誤日志 logging.error(error) # 發(fā)生錯(cuò)誤回滾 self.mydb.rollback() self.mydb.close()
imgurl = data['imgurl']
base = data['base']
intro = data['intro']
這三個(gè)變量,由于是初始抓取頁(yè)面分配到的參數(shù),再抓下一層分配的數(shù)據(jù)
實(shí)現(xiàn)的目的:把初始頁(yè)面抓到的數(shù)據(jù)+多個(gè)頁(yè)面的數(shù)據(jù),集合在一起,一次性入庫(kù)。
問題描述:現(xiàn)在就是初始抓到數(shù)據(jù),print后有三個(gè)數(shù)組,數(shù)據(jù)是初始頁(yè)面的,還有其它頁(yè)面,這樣就導(dǎo)致第一次imgurl,base,intro都會(huì)不存在,keyerror,嘗試判斷不存在,還是一直報(bào)錯(cuò),導(dǎo)致入庫(kù)一直失敗
求更好的解決方法~
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
我想要爬取搜狐新聞 網(wǎng)址是:
http://news.sohu.com/guoneixinwen.shtml
有很多頁(yè)需要爬取,按以往的一些網(wǎng)站,源碼會(huì)在下一頁(yè)按鈕的地方顯示出下一頁(yè)的href,然后我只要抓出這個(gè)href就可以爬到了。但上邊這個(gè)的下一頁(yè)是用js來(lái) 跳轉(zhuǎn)的,不知道這種情況該如何處理呢?
上一頁(yè) 下一頁(yè) 末頁(yè) 下邊是我原來(lái)的做法,該怎么改呢?
class CurrentPolitics(CrawlSpider): reload(sys) sys.setdefaultencoding('utf8') name = "Sohu_CurrentPolitics" #allowed_domains = ["http://news.sohu.com"] start_urls = [ ] def start_requests(self): for url in self.start_urls: yield Request(url) def __init__(self, **kwargs): path = "/CpsecSpiders/rules/sohu.xml" xmlpath = os.getcwd()+path print xmlpath DOMTree = xml.dom.minidom.parse(xmlpath) collection = DOMTree.documentElement spiders = collection.getElementsByTagName("spider") print spiders print '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' for spider in spiders: article_name1 = spider.getElementsByTagName('article_name')[0] self.article_name = article_name1.childNodes[0].data article_url1 = spider.getElementsByTagName('article_url')[0] self.article_url = article_url1.childNodes[0].data article_content1 = spider.getElementsByTagName('article_content')[0] self.article_content = article_content1.childNodes[0].data next_page_url1 = spider.getElementsByTagName('next_page_url')[0] self.next_page_url = next_page_url1.childNodes[0].data baseurl1 = spider.getElementsByTagName('base_url')[0] self.baseurl = baseurl1.childNodes[0].data article_author1 = spider.getElementsByTagName('article_author')[0] self.article_author = article_author1.childNodes[0].data article_time1 = spider.getElementsByTagName('article_time')[0] self.article_time = article_time1.childNodes[0].data article_click_num1 = spider.getElementsByTagName('article_click_num')[0] self.article_click_num = article_click_num1.childNodes[0].data article_reply_num1 = spider.getElementsByTagName('article_reply_num')[0] self.article_reply_num = article_reply_num1.childNodes[0].data start_url1 = spider.getElementsByTagName('start_url')[0] self.start_url = start_url1.childNodes[0].data self.start_urls = self.start_url.split(',') print self.start_urls #allowed_domains1 = spider.getElementsByTagName('allowed_domains')[0] #self.allowed_domains = allowed_domains1.childNodes[0].data def parse(self, response): #選擇器 sel = Selector(response) item = CpsecspidersItem() #文章url列表 article_url = sel.xpath(self.article_url).extract() #下一頁(yè)地址 next_page_url = sel.xpath(self.next_page_url).extract() for url in article_url: urll = urljoin(self.baseurl,url) request = scrapy.Request(urll,callback=self.parse_second) request.meta['item'] = item yield request #確認(rèn)有沒有下一頁(yè) if next_page_url[0]: print "next"+urljoin(self.baseurl,next_page_url[0]) request = scrapy.Request(urljoin(self.baseurl,next_page_url[0]),callback=self.parse) yield request def parse_second(self, response): content = '' sel = Selector(response) item = response.meta['item'] #文章信息采集 ####################################################################################################################### article_url = str(response.url) today_timestamp = sp.get_tody_timestamp() article_id = sp.hashForUrl(article_url) article_name = sel.xpath(self.article_name).extract() article_time = sel.xpath(self.article_time).extract() article_content = sel.xpath(self.article_content).extract() article_author = sel.xpath(self.article_author).extract() article_clik_num = sel.xpath(self.article_click_num).extract() article_reply_num = sel.xpath(self.article_reply_num).extract()
希望有大牛指點(diǎn)一下!
%3C/td%3E
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
需求:有個(gè)redis隊(duì)列,我需要從隊(duì)列中獲取數(shù)據(jù)(源相關(guān)的配置規(guī)則),然后加入到scrapy的spider中,并啟動(dòng)。
目前的解決方法:
開啟了個(gè)守護(hù)線程,使用scrapy的CrawlerRunner來(lái)啟動(dòng)。但是這樣在windows下運(yùn)行正常,在linux下,twisted使用的epoll一定時(shí)間內(nèi)沒有事件的話,dopoll方法進(jìn)入無(wú)限等待狀態(tài),加入新的爬蟲也不會(huì)爬取。
求教大神們,一般這種需求怎么搞。
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
python3.6
scrapy 1.4.0
斷點(diǎn)調(diào)試時(shí)可以看到數(shù)據(jù),但是命令行導(dǎo)出csv文件為空。
spider文件: import scrapy import re from lxml import etree from scrapy.http import Request from dingdian.items import DingdianItem ######################################################################## class myspider(scrapy.Spider): """""" name= 'dingdian' #allow_domains =['x23us.com'] base_url ='http://www.23us.so/list/' #---------------------------------------------------------------------- def __init__(self): """Constructor""" #---------------------------------------------------------------------- def start_requests(self): """""" for i in range(1,2): #url =self.base_url +str(i)+'_1.html' url ='http://www.23us.so/list/1_1.html' yield Request(url,self.parse) #yield Request('http://www.x23us.com/quanben/1',self.parse) def parse(self,response): #print(response.url) #初始網(wǎng)址正確 #print(response.text) #pattern =re.compile('
(.*?)') #pageIndex =re.findall(pattern, response) pageIndex= response.xpath('//a[@class="last"]/text()').extract() print(pageIndex) baseurl = str(response.url)[:-7] for num in range(1,int(pageIndex[0])-200): url =baseurl+'_'+str(num) +'.html' yield Request(url,callback=self.getname) #---------------------------------------------------------------------- def getname(self,response): """""" #contents= response.xpath('//a[@class="last"]/text()').extract() #print(pageIndex) tds =response.xpath('//tr[@bgcolor="#FFFFFF"]') for td in tds: novelname = td.xpath('./td[@class="L"]/a/text()').extract() novelurl =td.xpath('./td[@class="L"]/a/@href')[0].extract() yield Request(novelurl, callback=self.getcontent, meta={'name':novelname, 'url':novelname}) #---------------------------------------------------------------------- def getcontent(self,response): """""" item = DingdianItem() item['name']=str(response.meta['name']) item['novelurl']=response.url #novelurl = response.url tds =response.xpath('//table[@id="at"]') for td in tds: #author =td.xpath('//tr[1]/td[2]/text()').extract() item['author'] =td.xpath('//tr[1]/td[2]/text()').extract() #serialstatus=td.xpath('//tr[1]/td[3]/text()').extract() item['serialstatus'] =td.xpath('//tr[1]/td[3]/text()').extract() #lastupdatatime =td.xpath('//tr[2]/td[3]/text()').extract() item['lastupdatatime'] =td.xpath('//tr[2]/td[3]/text()').extract() #like = td.xpath('//tr[2]/td[1]/text()').extract() item['like'] =td.xpath('//tr[2]/td[1]/text()').extract() print(author,novelurl,serialstatus,lastupdatatime,like,) #item['author'] = response.xpath('//tbody/tr/td[1]') yield item # -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html from scrapy import signals import json import codecs import sys class DingdianPipeline(object): #---------------------------------------------------------------------- def __init__(self): self.file = codecs.open('dingdian.json', mode='wb', encoding='utf-8') def process_item(self, item, spider): pass ##link_url = item['link_url'] #file_name = link_url[7:-6].replace('/','_') #file_name += ".txt" #fp = open("dingdianspider.txt", 'w') #fp.write(item['name'],item['author'],item['novelurl'],item['serialstatus'],r"\n") #fp.close() #return item
# -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html from scrapy import signals import json import codecs import sys class DingdianPipeline(object): #---------------------------------------------------------------------- def __init__(self): self.file = codecs.open('dingdian.json', mode='wb', encoding='utf-8') def process_item(self, item, spider): pass ##link_url = item['link_url'] #file_name = link_url[7:-6].replace('/','_') #file_name += ".txt" #fp = open("dingdianspider.txt", 'w') #fp.write(item['name'],item['author'],item['novelurl'],item['serialstatus'],r"\n") #fp.close() #return item
item文件: # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # http://doc.scrapy.org/en/latest/topics/items.html import scrapy class DingdianItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() name = scrapy.Field() author = scrapy.Field() novelurl =scrapy.Field() serialstatus =scrapy.Field() lastupdatatime=scrapy.Field() like =scrapy.Field() #name_id =scrapy.Field()
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> # -*- coding: utf-8 -*- import scrapy from scrapy.shell import inspect_response from scrapy.http import Request, FormRequest #from scrapy.selector import Selector import requests import time import json class ZhihuSpider(scrapy.Spider): name = 'zhihu' allowed_domains = ['zhihu.com'] start_urls = ['https://zhihu.com/'] referer_url = "https://www.zhihu.com/" login_url = "https://www.zhihu.com/login/email" check_login_url = "https://www.zhihu.com/settings/profile" login_formdata = { 'email': 'xxxx', 'password': 'eee' } headers = { "Accept": "*/*", "Accept-Encoding": "gzip,deflate", "Accept-Language": "en-US,en;q=0.8,zh-TW;q=0.6,zh;q=0.4", "Connection": "keep-alive", "Upgrade-Insecure-Requests":"1", "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8", "X-Requested-With":"XMLHttpRequest", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36" } def start_requests(self): print('start_requests') self.headers['Referer'] = self.referer_url self.headers['Host'] = "www.zhihu.com" return [Request("https://www.zhihu.com", meta = {'cookiejar' : 1}, headers = self.headers,callback = self.post_login)] def captcha_handler(self, response): t = str(int(time.time() * 1000)) captcha_url = 'https://www.zhihu.com/captcha.gif?r=' + t + "&type=login" with open("code.jpg",'wb') as w: req=requests.Session() p=req.get(url=captcha_url,headers=self.headers) w.write(p.content) code=input("請(qǐng)輸入驗(yàn)證碼:") if not code: sys.exit(1) else: self.login_formdata["captcha"] = code def pre_signin_handler(self, response): #inspect_response(response,self) _xsrf = response.xpath('//input[@name="_xsrf"]/@value').extract_first() self.headers["X-Xsrftoken"] = _xsrf self.login_formdata['_xsrf'] = _xsrf print(self.login_formdata['_xsrf']) self.captcha_handler(response) def post_login(self, response): print('post_login') self.pre_signin_handler(response) print(self.login_formdata) #FormRequeset.from_response是Scrapy提供的一個(gè)函數(shù), 用于post表單 return FormRequest("https://www.zhihu.com/login/email",meta={'cookiejar':response.meta['cookiejar']}, headers = self.headers, formdata = { '_xsrf':self.login_formdata['_xsrf'], 'password':'xxxx', 'email':'eeee', 'captcha':self.login_formdata["captcha"], }, callback = self.__check_login_status, ) ''' return [FormRequest.from_response(response, meta ={'cookiejar' : 1},#cookies = self.cookies, headers = self.headers, #注意此處的headers formdata = self.login_formdata, callback = self.__check_login_status, url = self.login_url, dont_filter = True )] ''' def __check_login_status(self, response): # '用來(lái)檢測(cè)是否登陸成功' print("----__check_login_status----") print(eval(response.text)) if json.loads(response.text)['r'] == 0: print("登錄成功") else: print("登錄失敗") #from scrapy.shell import inspect_response #inspect_response(response, self) yield Request(self.check_login_url, meta = {'cookiejar' : 1}, headers=self.headers,callback=self.parse_user_detail) def parse_user_detail(self, response): print("----parse_user_detail----") #with open('response_of_user_detil.html','wb') as file: # file.write(response.body)
用scrapy模擬登錄知乎會(huì)出現(xiàn)驗(yàn)證碼失敗的情況,返回:
{'data': {'captcha': '驗(yàn)證碼會(huì)話無(wú)效 :(', 'name': 'ERR_VERIFY_CAPTCHA_SESSION_IN
VALID'}, 'msg': '驗(yàn)證碼會(huì)話無(wú)效 :(', 'r': 1, 'errcode': 1991829}
哪位大神有用scrapy模擬登錄過?清指點(diǎn)下,謝謝!
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 問題描述:想抓取某類列表頁(yè)中的新聞詳細(xì)頁(yè),其中遇見有的新聞詳細(xì)頁(yè)有翻頁(yè),就是一長(zhǎng)篇文章用分頁(yè)來(lái)隔開,有的則沒有。而我想儲(chǔ)存的mysql每行字段格式如下: domain, url, 標(biāo)題, 簡(jiǎn)介, 全部翻頁(yè)內(nèi)容 這樣才能方便生成網(wǎng)頁(yè),如果每個(gè)翻頁(yè)都是一行,那我想不到要怎么調(diào)用。我自己想的是能不能把所有翻頁(yè)正文都寫到item的一個(gè)key里,然后直接存到mysql中即可。mysql是實(shí)現(xiàn)了,但是spider.py總是不能實(shí)現(xiàn),卡了好幾天。。。還希望大家指點(diǎn)。 : ) 目前邏輯為:生成所有l(wèi)ist頁(yè)面翻頁(yè) -> 捕獲新聞頁(yè)url -> 獲取指定數(shù)據(jù), 提取翻頁(yè)鏈接回調(diào)給翻頁(yè)解析函數(shù) list頁(yè)面:http://www.cyone.com.cn/Article/chuangyegushi/pp/
有翻頁(yè)的新聞詳細(xì)頁(yè):http://www.cyone.com.cn/Article/Article_39110.html #List頁(yè)面中的第二條新聞
spider.py 如下:
# -*- coding:utf-8 -*- import scrapy from seo.items import SeoItem from scrapy.http import Request #from scrapy.loader import ItemLoader class DmozSpider(scrapy.Spider): name = 'seo' start_urls = [] #獲取全部翻頁(yè)鏈接 for pn in range(1,16): url = 'http://www.cyone.com.cn/Article/chuangyegushi/pp/List_%s.html' % pn start_urls.append(url) #獲取每頁(yè)的新聞URL def parse(self,response): urls = response.xpath('//*[@class="box4_a"]/a/@href').extract() for url in urls: url_new = 'http://www.cyone.com.cn' + url print ">>newsurl: %s" % url_new yield Request(url_new,callback=self.parse_item) #抓取新聞詳細(xì)頁(yè)內(nèi)容 def parse_item(self,response): item = SeoItem() item['domain'] = 'http://www.cyone.com.cn' item['url'] = response.request.url item['title'] = response.xpath('//*[@class="title4"]').extract()[0] item['summary'] = response.xpath('//*[@class="FIELDSET"]').extract()[0] item['content'] = response.xpath('//*[@class="left_co"]').extract()[0] pagelink = response.xpath('//*[@class="left_co"]//b/a/@href').extract() #獲取詳細(xì)頁(yè)翻頁(yè)鏈接 if not pagelink: self.log(">>> url: %s is not page!!" % response.url) item['page_content'] = "no" for link in pagelink: link_new = 'http://www.cyone.com.cn' + link print ">>>>>>>> link_new: %s" % link_new yield Request(link_new,callback=self.parse_page,meta={'item':item}) #制定parse_page為回調(diào),并傳遞item def parse_page(self,response): item = response.meta['item'] item['page_content'] = response.xpath('//*[@class="left_co"]').extract()[0] yield item
寫入mysql的piplines.py:
#coding:utf-8 import MySQLdb import json import codecs import re class MySQLStorePipeline(object): def __init__(self): self.conn = MySQLdb.connect("localhost", "root", "!QAZxsw2", "seo", charset="utf8", use_unicode=True) self.cursor = self.conn.cursor() def process_item(self, item, spider): try: self.cursor.execute("""INSERT INTO testnews (domain, url, title, summary, content, page_content) VALUES (%s, %s, %s, %s, %s, %s)""", (item['domain'], item['url'], item['title'], item['summary'], item['content'], item['page_content'])) self.conn.commit() except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) return item
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
我在用scrapy+redis實(shí)現(xiàn)一個(gè)簡(jiǎn)單的分布式爬蟲,但運(yùn)行后,一個(gè)爬蟲爬地快,一個(gè)爬蟲
爬地慢,我想請(qǐng)教各位如何實(shí)現(xiàn)redis對(duì)各個(gè)爬蟲獲取URL速度或者頻率的控制以達(dá)到均衡?
謝謝!
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
報(bào)錯(cuò)日志如下:
2017-07-12 21:26:48 [scrapy.pipelines.files] WARNING: File (code: 403): Error downloading file from referred in
2017-07-12 21:26:48 [scrapy.core.scraper] WARNING: Dropped: Item contains no images
紅色部分,是自己寫的代碼
def item_completed(self, results, item, info):
if item.__class__.__name__ != 'NewsImagesItem':
return item
image_path = [x['path'] for ok,x in results if ok]
if not image_path:
raise DropItem(' Item contains no images')
imagePipiline 配置都沒有錯(cuò)誤,日志里顯示圖片已經(jīng)開始下載
圖片地址也沒有錯(cuò)誤,部分圖片是可以下載下來(lái)的
另外:圖片地址在瀏覽器里多次嘗試也會(huì)出現(xiàn)403 Forbidden 錯(cuò)誤
應(yīng)該是網(wǎng)站的防爬策略,怎么解決呢
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 登錄部分代碼如下: def start_requests(self,user,passw): yield scrapy.FormRequest( url = self.login_url, headers = self.headers, formdata={ 'action': 'chk', 'username':muser, 'password':mpassw, }, meta = { 'cookiejar': 1 }, callback = self.request_yue )
現(xiàn)在好像只能運(yùn)行一次start_requests 我是把user和passw寫死了,現(xiàn)在是傳參的方式,但是怎么多次調(diào)用start_requests以登錄不同賬號(hào)呢?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
下面的代碼模擬登錄知乎,在登錄的時(shí)候沒有成功
check_login提示失敗:
check_login
{
"r": 1,
"errcode": 1991829,
"data": {"captcha":"驗(yàn)證碼會(huì)話無(wú)效 :(","name":"ERR_VERIFY_CAPTCHA_SESSION_INVALID"},
"msg": "驗(yàn)證碼會(huì)話無(wú)效 :("
}
有沒有兄弟有成功的經(jīng)驗(yàn),望指點(diǎn)一二,謝謝
# -*- coding: utf-8 -*-
import scrapy
import json
class ZhihuSpider(scrapy.Spider):
name = "zhihu"
allowed_domains = ["www.zhihu.com"]
headers = {
'Host': 'www.zhihu.com',
'Referer': 'http://www.zhihu.com',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36',
}
def start_requests(self):
# 返回值必須是一個(gè)序列
return [scrapy.Request('http://www.zhihu.com/#signin', callback=self.login)]
def login(self, response):
print('-------') # 便于測(cè)試
_xsrf = response.xpath('//input[@name="_xsrf"]/ @value ').extract()[0]
print(response.xpath('//input[@name="_xsrf"]/ @value '))
print(_xsrf)
return [scrapy.FormRequest(
url = 'http://www.zhihu.com/login/email', # 這是post的真實(shí)地址
formdata={
'_xsrf': _xsrf,
'email': 'xxxxxx', # email
'password': 'xxxxx', # password
'remember_me': 'true',
},
headers=self.headers,
callback=self.check_login,
)]
def check_login(self, response):
print("check_login")
print(response.text)
print("check_login ---")
if json.loads(response.text)['r'] == 0: ####這里提示登錄失敗
yield scrapy.Request(
'http://www.zhihu.com',
headers=self.headers,
callback=self.page_content,
dont_filter=True,
)
def page_content(self, response):
with open('first_page.html', 'wb') as f:
f.write(response.body)
print('done')
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
Scrapy 是不是不能爬取https的網(wǎng)站?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
Rails 框架,當(dāng)出現(xiàn)瀏覽器路徑訪問錯(cuò)誤時(shí)如何捕獲,處理?
清楚的答案 或 思路 或 參考資料 都可以。
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> Exiting /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- core/rmagick (LoadError) from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:312:in `depend_on' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:225:in `require_dependency' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:444:in `block (2 levels) in eager_load!' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:443:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:443:in `block in eager_load!' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:441:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:441:in `eager_load!' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application/finisher.rb:53:in `block in ' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `instance_exec' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `run' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:55:in `block in run_initializers' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `run_initializers' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application.rb:136:in `initialize!' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing' from /usr/local/redmine/config/environment.rb:14:in `' from /usr/local/redmine/config.ru:3:in `require' from /usr/local/redmine/config.ru:3:in `block in ' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize' from /usr/local/redmine/config.ru:in `new' from /usr/local/redmine/config.ru:in `' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/server.rb:46:in `app' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/server.rb:70:in `start' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:55:in `block in ' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:50:in `' from script/rails:6:in `require' from script/rails:6:in `'
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
硬盤本來(lái)1T的,不知道怎么只在home目錄,所以通過重新分配,把HOME的容量釋放出來(lái),并增加至ROOT目錄下。
然后通過# ruby script/rails server webrick -e production 無(wú)法啟動(dòng)了,下面是報(bào)錯(cuò)信息。實(shí)在搞不清楚是什么問題。麻煩各位指點(diǎn)下。 => Booting WEBrick => Rails 3.2.16 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2/client.rb:70:in `connect': Unknown database 'redmine_development' (Mysql2::Error) from /usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.16/lib/mysql2/client.rb:70:in `initialize' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout' from /usr/local/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection' from /usr/local/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/model_schema.rb:224:in `table_exists?' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/attribute_methods/primary_key.rb:75:in `get_primary_key' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/attribute_methods/primary_key.rb:60:in `reset_primary_key' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/attribute_methods/primary_key.rb:49:in `primary_key' from /usr/local/lib/ruby/gems/2.0.0/gems/activerecord-3.2.16/lib/active_record/attribute_assignment.rb:13:in `attributes_protected_by_default' from /usr/local/lib/ruby/gems/2.0.0/gems/activemodel-3.2.16/lib/active_model/mass_assignment_security.rb:216:in `block in protected_attributes_configs' from /usr/local/lib/ruby/gems/2.0.0/gems/activemodel-3.2.16/lib/active_model/mass_assignment_security.rb:188:in `yield' from /usr/local/lib/ruby/gems/2.0.0/gems/activemodel-3.2.16/lib/active_model/mass_assignment_security.rb:188:in `protected_attributes' from /usr/local/lib/ruby/gems/2.0.0/gems/activemodel-3.2.16/lib/active_model/mass_assignment_security.rb:118:in `block in attr_protected' from /usr/local/lib/ruby/gems/2.0.0/gems/activemodel-3.2.16/lib/active_model/mass_assignment_security.rb:117:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/activemodel-3.2.16/lib/active_model/mass_assignment_security.rb:117:in `attr_protected' from /usr/local/redmine/app/models/issue_relation.rb:73:in `' from /usr/local/redmine/app/models/issue_relation.rb:18:in `' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:469:in `load' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:469:in `block in load_file' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:639:in `new_constants_in' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:468:in `load_file' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:353:in `require_or_load' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:502:in `load_missing_constant' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:192:in `block in const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:514:in `load_missing_constant' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:192:in `block in const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:514:in `load_missing_constant' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:192:in `block in const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:514:in `load_missing_constant' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:192:in `block in const_missing' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:190:in `const_missing' from /usr/local/redmine/lib/redmine/helpers/gantt.rb:28:in `' from /usr/local/redmine/lib/redmine/helpers/gantt.rb:21:in `' from /usr/local/redmine/lib/redmine/helpers/gantt.rb:19:in `' from /usr/local/redmine/lib/redmine/helpers/gantt.rb:18:in `' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `require' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `block in require' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236:in `load_dependency' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `require' from /usr/local/redmine/lib/redmine.rb:51:in `' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `require' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `block in require' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236:in `load_dependency' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:251:in `require' from /usr/local/redmine/config/initializers/30-redmine.rb:4:in `' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `load' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `block in load' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:236:in `load_dependency' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/dependencies.rb:245:in `load' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:593:in `block (2 levels) in ' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:592:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/engine.rb:592:in `block in ' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `instance_exec' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `run' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:55:in `block in run_initializers' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `each' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `run_initializers' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application.rb:136:in `initialize!' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing' from /usr/local/redmine/config/environment.rb:14:in `' from /usr/local/redmine/config.ru:3:in `require' from /usr/local/redmine/config.ru:3:in `block in ' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize' from /usr/local/redmine/config.ru:in `new' from /usr/local/redmine/config.ru:in `' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/server.rb:46:in `app' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app' from /usr/local/lib/ruby/gems/2.0.0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/server.rb:70:in `start' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:55:in `block in ' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:50:in `' from script/rails:6:in `require' from script/rails:6:in `'
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
這個(gè)是我的gem
這個(gè)是書上的gem
他這個(gè)我很多操作都完不成,比如書上的命令: bundle exec guard init 我會(huì)出錯(cuò),bundler: command not found: guardInstall missing gem executables with `bundle install`
應(yīng)該怎么辦呢? 求大神解救, 怎么加入gem ?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
剛剛看到 @moli 寫的代碼,get 到 try 方法很好用。于是順便貼一下其 API
try(*a, &b)
Invokes the public method whose name goes as first argument just like public_send does, except that if the receiver does not respond to it the call returns nil rather than raising an exception.
This method is defined to be able to write
@person .try( :name )
instead of
@person .name if@person
try calls can be chained:
@person .try( :spouse ).try( :name )
instead of
@person .spouse.name if@person && @person .spouse
try will also return nil if the receiver does not respond to the method:
@person .try( :non_existing_method ) # => nil
instead of
@person .non_existing_method if@person .respond_to?( :non_existing_method ) # => nil
try returns nil when called on nil regardless of whether it responds to the method:
nil.try( :to_i ) # => nil, rather than 0
Arguments and blocks are forwarded to the method if invoked:
@posts .try( :each_slice , 2 ) do|a, b|
...
end
The number of arguments in the signature must match. If the object responds to the method the call is attempted and ArgumentError is still raised in case of argument mismatch.
If try is called without arguments it yields the receiver to a given block unless it is nil :
@person .try do|p|
...
end
You can also call try with a block without accepting an argument, and the block will be instance_eval'ed instead:
@person .try { upcase.truncate( 50 ) }
Please also note that try is defined on Object . Therefore, it won't work with instances of classes that do not have Object among their ancestors, like direct subclasses of BasicObject .
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
有下面這幾種方案
具體的配置
Nginx 通用配置 :
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
Nginx -> Apache
server {
listen 80;
server_name site1.com;
access_log off;
error_log off;
location / {
proxy_pass http://127.0.0.1:81/ ;
}
}
Nginx -> Thin
upstream takefive {
server unix:/var/www/vhosts/site2.com/httpdocs/current/tmp/sockets/thin.0.sock;
}
server {
listen 80;
server_name site2.com;
access_log off;
error_log off;
location / {
proxy_pass http://127.0.0.1:81;
}
}
Nginx -> Unicorn
upstream site3 {
server unix:/var/www/vhosts/site3.com/httpdocs/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name site3.com;
access_log off;
error_log off;
location / {
proxy_pass http://127.0.0.1:81;
}
}
哪一種方案最佳呢??
網(wǎng)上的答案:如果內(nèi)存不是問題,那么 Unicorn + Nginx 是一個(gè)很好的選擇,否則可以考慮 Passenger + Nginx
各位有經(jīng)驗(yàn)的來(lái)談?wù)劙?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 如題,局部視圖中的ajax表單無(wú)法以post方法提交訪問create,怎么回事? <%= form_for @blog_sort ,remote: true, url: { action: :create,method: :post} do |f| %> <%= f.text_field :sort_name %> <%= f.submit %> <% end %> 上面這是局部視圖中的代碼,同樣的代碼放到主制圖index.html.erb中就可以。 我看了編譯為html的源碼,都是一樣的。但局部視圖中確實(shí)以get的方式訪問了index方法而不上create,怎么辦?急
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
我在win7下用railsinstaller-2.2.1安裝了ruby 、rubygems、sqlite3等等,也就是一鍵安裝的,然后想新建一個(gè)blog,在 run bundle install的時(shí)候出錯(cuò)了
然后,我嘗試了把blog目錄下的gemfile文件中的gem源改成了https://ruby.taobao.org,再bundle install,又報(bào)了下面的錯(cuò)誤
我是新手一枚,請(qǐng)高手們幫我看看這個(gè)問題,謝謝!
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> D, [2016-04-13T14:40:00.609856 #3494] DEBUG -- : (0.1ms) begin transactionD, [2016-04-13T14:40:00.609955 #3494] DEBUG -- : (0.1ms) begin transaction D, [2016-04-13T14:40:00.613431 #3494] DEBUG -- : User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '12312123123' LIMIT 1 D, [2016-04-13T14:40:00.613537 #3494] DEBUG -- : User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = '12312123123' LIMIT 1 D, [2016-04-13T14:40:00.640318 #3494] DEBUG -- : SQL (0.4ms) INSERT INTO "users" ("created_at", "email", "encrypted_password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2016-04-13 06:40:00.613720"], ["email", "12312123123"], ["encrypted_password", "123123"], ["updated_at", "2016-04-13 06:40:00.613720"]] D, [2016-04-13T14:40:00.640442 #3494] DEBUG -- : SQL (0.4ms) INSERT INTO "users" ("created_at", "email", "encrypted_password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", "2016-04-13 06:40:00.613720"], ["email", "12312123123"], ["encrypted_password", "123123"], ["updated_at", "2016-04-13 06:40:00.613720"]] D, [2016-04-13T14:40:00.826313 #3494] DEBUG -- : (185.4ms) commit transaction D, [2016-04-13T14:40:00.826405 #3494] DEBUG -- : (185.4ms) commit transaction 恭喜,程序執(zhí)行正常,未發(fā)生任何異常或錯(cuò)誤。 請(qǐng)注意,程序即將退出。 I, [2016-04-13T14:40:00.826637 #3494] INFO -- : 注冊(cè)方法的返回值["12312123123", "123123", "離線"] I, [2016-04-13T14:40:00.826680 #3494] INFO -- : 注冊(cè)方法的返回值["12312123123", "123123", "離線"] I, [2016-04-13T14:40:00.826771 #3494] INFO -- : Admin::RegisterController#create 注冊(cè)成功! I, [2016-04-13T14:40:00.826806 #3494] INFO -- : Admin::RegisterController#create 注冊(cè)成功! I, [2016-04-13T14:40:00.827509 #3494] INFO -- : Redirected to http://0.0.0.0:3000/admin/register I, [2016-04-13T14:40:00.827576 #3494] INFO -- : Redirected to http://0.0.0.0:3000/admin/register I, [2016-04-13T14:40:00.827853 #3494] INFO -- : Completed 302 Found in 219ms (ActiveRecord: 186.1ms) I, [2016-04-13T14:40:00.827941 #3494] INFO -- : Completed 302 Found in 219ms (ActiveRecord: 186.1ms) D, [2016-04-13T14:40:00.832794 #3494] DEBUG -- : D, [2016-04-13T14:40:00.832853 #3494] DEBUG -- : D, [2016-04-13T14:40:00.832897 #3494] DEBUG -- : D, [2016-04-13T14:40:00.832934 #3494] DEBUG -- : I, [2016-04-13T14:40:00.833034 #3494] INFO -- : Started GET "/admin/register" for 127.0.0.1 at 2016-04-13 14:40:00 +0800 I, [2016-04-13T14:40:00.833066 #3494] INFO -- : Started GET "/admin/register" for 127.0.0.1 at 2016-04-13 14:40:00 +0800 I, [2016-04-13T14:40:00.834831 #3494] INFO -- : Processing by Admin::RegisterController#show as HTML I, [2016-04-13T14:40:00.834886 #3494] INFO -- : Processing by Admin::RegisterController#show as HTML I, [2016-04-13T14:40:00.836547 #3494] INFO -- : Rendered admin/register/show.html.erb within layouts/application (0.0ms) I, [2016-04-13T14:40:00.836593 #3494] INFO -- : Rendered admin/register/show.html.erb within layouts/application (0.0ms) I, [2016-04-13T14:40:00.950169 #3494] INFO -- : Completed 200 OK in 115ms (Views: 114.7ms | ActiveRecord: 0.0ms) I, [2016-04-13T14:40:00.950242 #3494] INFO -- : Completed 200 OK in 115ms (Views: 114.7ms | ActiveRecord: 0.0ms) D, [2016-04-13T14:40:01.015440 #3494] DEBUG -- : D, [2016-04-13T14:40:01.021302 #3494] DEBUG -- : D, [2016-04-13T14:40:01.021402 #3494] DEBUG -- : D, [2016-04-13T14:40:01.021443 #3494] DEBUG -- : I, [2016-04-13T14:40:01.028709 #3494] INFO -- : Started GET "/assets/admin/login_session.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.028792 #3494] INFO -- : Started GET "/assets/admin/login_session.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.035617 #3494] DEBUG -- : D, [2016-04-13T14:40:01.036020 #3494] DEBUG -- : D, [2016-04-13T14:40:01.036700 #3494] DEBUG -- : D, [2016-04-13T14:40:01.036881 #3494] DEBUG -- : I, [2016-04-13T14:40:01.037218 #3494] INFO -- : Started GET "/assets/bootstrap_and_overrides.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.037290 #3494] INFO -- : Started GET "/assets/bootstrap_and_overrides.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.039909 #3494] DEBUG -- : D, [2016-04-13T14:40:01.041696 #3494] DEBUG -- : D, [2016-04-13T14:40:01.041872 #3494] DEBUG -- : D, [2016-04-13T14:40:01.041927 #3494] DEBUG -- : I, [2016-04-13T14:40:01.042101 #3494] INFO -- : Started GET "/assets/posts.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.042404 #3494] INFO -- : Started GET "/assets/posts.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.044271 #3494] DEBUG -- : D, [2016-04-13T14:40:01.044416 #3494] DEBUG -- : D, [2016-04-13T14:40:01.044466 #3494] DEBUG -- : D, [2016-04-13T14:40:01.044508 #3494] DEBUG -- : I, [2016-04-13T14:40:01.044691 #3494] INFO -- : Started GET "/assets/scaffolds.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.044737 #3494] INFO -- : Started GET "/assets/scaffolds.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.046715 #3494] DEBUG -- : D, [2016-04-13T14:40:01.047172 #3494] DEBUG -- : D, [2016-04-13T14:40:01.047424 #3494] DEBUG -- : D, [2016-04-13T14:40:01.047519 #3494] DEBUG -- : I, [2016-04-13T14:40:01.047969 #3494] INFO -- : Started GET "/assets/admin/register.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.048026 #3494] INFO -- : Started GET "/assets/admin/register.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.050567 #3494] DEBUG -- : D, [2016-04-13T14:40:01.050764 #3494] DEBUG -- : D, [2016-04-13T14:40:01.051097 #3494] DEBUG -- : D, [2016-04-13T14:40:01.051167 #3494] DEBUG -- : I, [2016-04-13T14:40:01.054233 #3494] INFO -- : Started GET "/assets/admin/log_out.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.057832 #3494] INFO -- : Started GET "/assets/admin/log_out.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.064639 #3494] DEBUG -- : D, [2016-04-13T14:40:01.064864 #3494] DEBUG -- : D, [2016-04-13T14:40:01.064921 #3494] DEBUG -- : D, [2016-04-13T14:40:01.064966 #3494] DEBUG -- : I, [2016-04-13T14:40:01.065143 #3494] INFO -- : Started GET "/assets/style.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.065192 #3494] INFO -- : Started GET "/assets/style.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.068474 #3494] DEBUG -- : D, [2016-04-13T14:40:01.068580 #3494] DEBUG -- : D, [2016-04-13T14:40:01.068629 #3494] DEBUG -- : D, [2016-04-13T14:40:01.068673 #3494] DEBUG -- : I, [2016-04-13T14:40:01.068930 #3494] INFO -- : Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.068984 #3494] INFO -- : Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.071873 #3494] DEBUG -- : D, [2016-04-13T14:40:01.071957 #3494] DEBUG -- : D, [2016-04-13T14:40:01.072009 #3494] DEBUG -- : D, [2016-04-13T14:40:01.072051 #3494] DEBUG -- : I, [2016-04-13T14:40:01.072232 #3494] INFO -- : Started GET "/assets/welcome.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.072278 #3494] INFO -- : Started GET "/assets/welcome.css?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.076079 #3494] DEBUG -- : D, [2016-04-13T14:40:01.076177 #3494] DEBUG -- : D, [2016-04-13T14:40:01.076232 #3494] DEBUG -- : D, [2016-04-13T14:40:01.081164 #3494] DEBUG -- : I, [2016-04-13T14:40:01.083933 #3494] INFO -- : Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.083981 #3494] INFO -- : Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.085751 #3494] DEBUG -- : D, [2016-04-13T14:40:01.085927 #3494] DEBUG -- : D, [2016-04-13T14:40:01.085984 #3494] DEBUG -- : D, [2016-04-13T14:40:01.086027 #3494] DEBUG -- : I, [2016-04-13T14:40:01.086211 #3494] INFO -- : Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.086257 #3494] INFO -- : Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.091283 #3494] DEBUG -- : D, [2016-04-13T14:40:01.091522 #3494] DEBUG -- : D, [2016-04-13T14:40:01.091772 #3494] DEBUG -- : D, [2016-04-13T14:40:01.091884 #3494] DEBUG -- : I, [2016-04-13T14:40:01.092155 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/transition.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.092261 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/transition.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.098301 #3494] DEBUG -- : D, [2016-04-13T14:40:01.100339 #3494] DEBUG -- : D, [2016-04-13T14:40:01.100584 #3494] DEBUG -- : D, [2016-04-13T14:40:01.100662 #3494] DEBUG -- : I, [2016-04-13T14:40:01.100842 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/modal.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.100917 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/modal.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.105913 #3494] DEBUG -- : D, [2016-04-13T14:40:01.106076 #3494] DEBUG -- : D, [2016-04-13T14:40:01.106171 #3494] DEBUG -- : D, [2016-04-13T14:40:01.106260 #3494] DEBUG -- : I, [2016-04-13T14:40:01.106500 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/alert.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.106599 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/alert.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.109156 #3494] DEBUG -- : D, [2016-04-13T14:40:01.109366 #3494] DEBUG -- : D, [2016-04-13T14:40:01.109422 #3494] DEBUG -- : D, [2016-04-13T14:40:01.109471 #3494] DEBUG -- : I, [2016-04-13T14:40:01.111641 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/dropdown.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.111705 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/dropdown.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.113917 #3494] DEBUG -- : D, [2016-04-13T14:40:01.115927 #3494] DEBUG -- : D, [2016-04-13T14:40:01.116031 #3494] DEBUG -- : D, [2016-04-13T14:40:01.116107 #3494] DEBUG -- : I, [2016-04-13T14:40:01.116295 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/scrollspy.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.117720 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/scrollspy.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.120582 #3494] DEBUG -- : D, [2016-04-13T14:40:01.120767 #3494] DEBUG -- : D, [2016-04-13T14:40:01.120873 #3494] DEBUG -- : D, [2016-04-13T14:40:01.120966 #3494] DEBUG -- : I, [2016-04-13T14:40:01.121216 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/tab.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.121320 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/tab.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.129800 #3494] DEBUG -- : D, [2016-04-13T14:40:01.129880 #3494] DEBUG -- : D, [2016-04-13T14:40:01.129922 #3494] DEBUG -- : D, [2016-04-13T14:40:01.131419 #3494] DEBUG -- : I, [2016-04-13T14:40:01.131554 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/tooltip.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.131606 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/tooltip.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.133439 #3494] DEBUG -- : D, [2016-04-13T14:40:01.133619 #3494] DEBUG -- : D, [2016-04-13T14:40:01.133705 #3494] DEBUG -- : D, [2016-04-13T14:40:01.133746 #3494] DEBUG -- : I, [2016-04-13T14:40:01.133901 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/popover.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.133944 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/popover.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.136452 #3494] DEBUG -- : D, [2016-04-13T14:40:01.136524 #3494] DEBUG -- : D, [2016-04-13T14:40:01.138778 #3494] DEBUG -- : D, [2016-04-13T14:40:01.138849 #3494] DEBUG -- : I, [2016-04-13T14:40:01.140422 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/button.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.140499 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/button.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.142444 #3494] DEBUG -- : D, [2016-04-13T14:40:01.142599 #3494] DEBUG -- : D, [2016-04-13T14:40:01.142652 #3494] DEBUG -- : D, [2016-04-13T14:40:01.142693 #3494] DEBUG -- : I, [2016-04-13T14:40:01.142858 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/collapse.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.142903 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/collapse.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.144861 #3494] DEBUG -- : D, [2016-04-13T14:40:01.146987 #3494] DEBUG -- : D, [2016-04-13T14:40:01.147049 #3494] DEBUG -- : D, [2016-04-13T14:40:01.148444 #3494] DEBUG -- : I, [2016-04-13T14:40:01.148619 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/carousel.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.148654 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/carousel.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.150395 #3494] DEBUG -- : D, [2016-04-13T14:40:01.150552 #3494] DEBUG -- : D, [2016-04-13T14:40:01.150601 #3494] DEBUG -- : D, [2016-04-13T14:40:01.150643 #3494] DEBUG -- : I, [2016-04-13T14:40:01.150807 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/affix.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.150856 #3494] INFO -- : Started GET "/assets/twitter/bootstrap/affix.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.157956 #3494] DEBUG -- : D, [2016-04-13T14:40:01.158016 #3494] DEBUG -- : D, [2016-04-13T14:40:01.158072 #3494] DEBUG -- : D, [2016-04-13T14:40:01.158112 #3494] DEBUG -- : I, [2016-04-13T14:40:01.158251 #3494] INFO -- : Started GET "/assets/twitter/bootstrap.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.158290 #3494] INFO -- : Started GET "/assets/twitter/bootstrap.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.160151 #3494] DEBUG -- : D, [2016-04-13T14:40:01.160219 #3494] DEBUG -- : D, [2016-04-13T14:40:01.160282 #3494] DEBUG -- : D, [2016-04-13T14:40:01.160327 #3494] DEBUG -- : I, [2016-04-13T14:40:01.160441 #3494] INFO -- : Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.160468 #3494] INFO -- : Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.163302 #3494] DEBUG -- : D, [2016-04-13T14:40:01.163488 #3494] DEBUG -- : D, [2016-04-13T14:40:01.164975 #3494] DEBUG -- : D, [2016-04-13T14:40:01.165019 #3494] DEBUG -- : I, [2016-04-13T14:40:01.167372 #3494] INFO -- : Started GET "/assets/admin/log_out.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.170578 #3494] INFO -- : Started GET "/assets/admin/log_out.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.172917 #3494] DEBUG -- : D, [2016-04-13T14:40:01.173083 #3494] DEBUG -- : D, [2016-04-13T14:40:01.173138 #3494] DEBUG -- : D, [2016-04-13T14:40:01.173183 #3494] DEBUG -- : I, [2016-04-13T14:40:01.173375 #3494] INFO -- : Started GET "/assets/admin/login_session.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.173428 #3494] INFO -- : Started GET "/assets/admin/login_session.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.179715 #3494] DEBUG -- : D, [2016-04-13T14:40:01.179811 #3494] DEBUG -- : D, [2016-04-13T14:40:01.179858 #3494] DEBUG -- : D, [2016-04-13T14:40:01.179907 #3494] DEBUG -- : I, [2016-04-13T14:40:01.180119 #3494] INFO -- : Started GET "/assets/admin/register.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.180170 #3494] INFO -- : Started GET "/assets/admin/register.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.183229 #3494] DEBUG -- : D, [2016-04-13T14:40:01.183394 #3494] DEBUG -- : D, [2016-04-13T14:40:01.183438 #3494] DEBUG -- : D, [2016-04-13T14:40:01.183478 #3494] DEBUG -- : I, [2016-04-13T14:40:01.186960 #3494] INFO -- : Started GET "/assets/posts.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.187036 #3494] INFO -- : Started GET "/assets/posts.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.188810 #3494] DEBUG -- : D, [2016-04-13T14:40:01.189002 #3494] DEBUG -- : D, [2016-04-13T14:40:01.189058 #3494] DEBUG -- : D, [2016-04-13T14:40:01.189100 #3494] DEBUG -- : I, [2016-04-13T14:40:01.189264 #3494] INFO -- : Started GET "/assets/bootstrap.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.189310 #3494] INFO -- : Started GET "/assets/bootstrap.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.191702 #3494] DEBUG -- : D, [2016-04-13T14:40:01.192578 #3494] DEBUG -- : D, [2016-04-13T14:40:01.192637 #3494] DEBUG -- : D, [2016-04-13T14:40:01.192676 #3494] DEBUG -- : I, [2016-04-13T14:40:01.192839 #3494] INFO -- : Started GET "/assets/welcome.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.192883 #3494] INFO -- : Started GET "/assets/welcome.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 D, [2016-04-13T14:40:01.194565 #3494] DEBUG -- : D, [2016-04-13T14:40:01.194629 #3494] DEBUG -- : D, [2016-04-13T14:40:01.194779 #3494] DEBUG -- : D, [2016-04-13T14:40:01.194872 #3494] DEBUG -- : I, [2016-04-13T14:40:01.195095 #3494] INFO -- : Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800 I, [2016-04-13T14:40:01.195215 #3494] INFO -- : Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2016-04-13 14:40:01 +0800
如題,上面是我的控制臺(tái)顯示的信息,全部都是雙列,是日志的問題還是程序的問題?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
ruby 2.2 + Rails4.1
我在我的PostsControllTest 中寫了一個(gè)測(cè)試方法
通過assert_routing() 對(duì)路由的路徑進(jìn)行測(cè)試,但我不知道/posts/1/edit 這個(gè)路徑該怎么寫,求救?
另:當(dāng)為控制器做功能性測(cè)試時(shí)如何測(cè)試show方法的的訪問,因?yàn)檫@個(gè)方法好像需要id 和 實(shí)例變量啊,該怎么傳入呢?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 最近在做Ruby代碼審查工作,大神們有什么好的Ruby語(yǔ)言代碼審查工具嗎?求推薦一款,謝謝!
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
Need to check if a block of attributes has changed before update in Rails
場(chǎng)景:使用 Active record 的 rails 項(xiàng)目
例如 user 表有個(gè) name 字段,在更新用戶名之前我們由于某種需求檢測(cè) name 字段是否被修改,那么我們通過 /modles/user.rb 產(chǎn)生的對(duì)象 user 來(lái)檢測(cè) name 字段是否被修改:
user.name_changed?
更多信息請(qǐng)參考 http://api.rubyonrails.org/classes/ActiveModel/Dirty.html
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> ror現(xiàn)在一般用什么服務(wù)器架構(gòu)部署呢
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
我有兩個(gè)Rails正則表達(dá)式,
/\A[a-z0-9_\-@\.]*\z/i
/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
哪位大神能幫我轉(zhuǎn)換成java的嗎,頭都看暈了,謝謝
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
源代碼:public class SendEmail {
public static void main(String[] args) {
// 收件人電子郵箱
String to = " a@xx.com.cn ";
// 發(fā)件人電子郵箱
String from = " b@xx.com.cn ";
// 指定發(fā)送郵件的主機(jī)為 localhost
String host = "hikml.xxxx .com.cn";
// 獲取系統(tǒng)屬性
Properties properties = System.getProperties();
// 設(shè)置郵件服務(wù)器
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", "25");
properties.setProperty("mail.transport.protocol", "smtp");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.user", " a@xx.com.cn ");
properties.put("mail.smtp.password", " ******* ");
// 獲取默認(rèn)session對(duì)象
Session session = Session.getDefaultInstance(properties);
session.setDebug(true);
try {
// 創(chuàng)建默認(rèn)的 MimeMessage 對(duì)象
MimeMessage message = new MimeMessage(session);
// Set From: 頭部頭字段
message.setFrom(new InternetAddress(from));
// Set To: 頭部頭字段
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
// Set Subject: 頭部頭字段
message.setSubject("This is the Subject Line!");
// 設(shè)置消息體
message.setText("This is actual message");
// 發(fā)送消息
Transport.send(message);
System.out.println("Sent message successfully....");
} catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
就是網(wǎng)上的一個(gè)初級(jí)教程,但是一直調(diào)不通。hikml.xxxx .com.cn這是公司內(nèi)部郵件服務(wù)器。能平通,使用25端口能telnet連通。
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> JAVAMAIL 收取郵件時(shí),如何排重呢? 假如我第一次收取郵件后,插入到數(shù)據(jù)庫(kù)了,第二次又接收,怎么判斷已經(jīng)接收過那些郵件呢?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 最近客戶生產(chǎn)環(huán)境郵件主題亂碼,亂碼如下=?ANSI_X3.4-1968?B?Pz8/P0lOQzA2ODQ1OD8/Pz8/Pw==?= ,而且郵件類型的附件找不到,但是附件是存在的,導(dǎo)出doc的文件也是亂碼,本機(jī)和測(cè)試環(huán)境都沒有問題,測(cè)試環(huán)境和生產(chǎn)環(huán)境一樣,用的同一個(gè)war包進(jìn)行的發(fā)布,有人遇到過這樣的問題嗎?
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> DEBUG: JavaMail version 1.4.1DEBUG: not loading file: D:\tools\MyEclipse8.6\binary\com.sun.java.jdk.win32.x86_1.6.0.013\jre\lib\javamail.providers DEBUG: java.io.FileNotFoundException: D:\tools\MyEclipse8.6\binary\com.sun.java.jdk.win32.x86_1.6.0.013\jre\lib\javamail.providers (系統(tǒng)找不到指定的文件。) DEBUG: !anyLoaded DEBUG: not loading resource: /META-INF/javamail.providers DEBUG: successfully loaded resource: /META-INF/javamail.default.providers DEBUG: Tables of loaded providers DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]} DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]} DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map DEBUG: !anyLoaded DEBUG: not loading resource: /META-INF/javamail.address.map DEBUG: not loading file: D:\tools\MyEclipse8.6\binary\com.sun.java.jdk.win32.x86_1.6.0.013\jre\lib\javamail.address.map
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>>
亂碼代碼:蘋果在線商店招行信用卡分期享5倍積分,3期更惠? =?gb2312?B?7TDA+8+iMMrW0Pi30aOoQUSjqQ?=
使用MimeUtility.decodeText方法無(wú)法解析該類容,請(qǐng)問做過類似東西的朋友們,有什么更好的轉(zhuǎn)碼方式嗎?
而且直接mimeMessage.getSubject()出來(lái)的就有? 這樣的一個(gè)亂碼,
但是我用其他郵件客戶端接收出來(lái)的是正確的。
HDC調(diào)試需求開發(fā)(15萬(wàn)預(yù)算),能者速來(lái)!>>> 如題, 不是群發(fā), 是群發(fā)單顯, 群發(fā)送郵件,但是收件人看到的收件人是自己。